SSH (Secure Shell) is a network protocol used for securely transferring data between computers. SSH allows a secure connection to be established between a client and a server, allowing data to be transferred encrypted.
One of the ways SSH can be used to increase the security of a connection is through the use of SSH keys. These are unique cryptographic keys used to verify a user’s identity and to grant access to a system.
In this article, I will explain how to generate and use SSH keys on the five most popular SSH clients: OpenSSH, PuTTY, SecureCRT, Bitvise SSH Client and Termius. I will explain this for Windows, macOS and Linux operating systems.
Generating SSH keys.
To generate SSH keys, you need a program capable of creating and storing cryptographic keys. This can be done using a command-line tool or via a graphical user interface.
OpenSSH (Windows, macOS, Linux)
OpenSSH is the default SSH client on most Linux distributions and is also available on macOS and Windows. To generate SSH keys using OpenSSH, follow the following steps:
- Open a terminal window.
- Type
ssh-keygen
and press Enter. - Follow the on-screen instructions to generate and save the keys.
PuTTY (Windows)
PuTTY is a popular SSH client for Windows. To generate SSH keys using PuTTY, follow the following steps:
- Open PuTTYgen.
- Select the desired key type (e.g., RSA or DSA).
- Click “Generate” to generate the key.
- Save the key.
SecureCRT (Windows, macOS).
SecureCRT is a commercial SSH client for Windows and macOS. To generate SSH keys with SecureCRT, follow the following steps:
- Click “Tools” in the menu bar and select “Create Public Key.”
- Select the desired key type (for example, RSA or DSA).
- Click “Generate” to generate the key.
- Save the key.
Bitvise SSH Client (Windows)
Bitvise SSH Client is a free SSH client for Windows. To generate SSH keys with Bitvise SSH Client, follow the following steps:
- Open Bitvise SSH Client.
- Click on “Client key manager” in the menu bar.
- Click “Generate new” to generate the key.
- Save the key.
Termius (Windows, macOS, Linux)
Termius is a multi-platform SSH client available for Windows, macOS and Linux. To generate SSH keys with Termius, follow the following steps:
- Click on “SSH Keys” in the sidebar.
- Click on “Generate
- Select the desired key type (for example, RSA or ECDSA).
- Click “Generate” to generate the key.
- Save the key.
Using SSH keys.
Once you have generated SSH keys, you need to add them to the list of authorized keys on the server you want to log in to. This can be done by adding the contents of the public key (for example, id_rsa.pub
) to the file ~/.ssh/authorized_keys
on the server.
To connect to a server using SSH keys, you must specify the correct path to the keys on your local machine. This can be done using the -i
option of the ssh
command. For example:
`ssh -i ~/.ssh/id_rsa user@server.example.com``
This command connects to server.example.com
as user user
and uses the key stored in the file ~/.ssh/id_rsa
.
OpenSSH (Windows, macOS, Linux)
In OpenSSH, using SSH keys is the default method for logging into a server. Once you have generated SSH keys, you do not need to take any additional steps to use them when logging in to a server.
PuTTY (Windows).
To use SSH keys in PuTTY, you must specify the key in PuTTY’s control panel. This can be done by following the following steps:
- Open PuTTY.
- Fill in the Host Name field with the name or IP address of the server you want to log in to.
- Click “SSH” on the left menu and then “Auth”.
- Click “Browse” next to the “Private key file for authentication” field and select the key you want to use.
- Click “Open” to connect to the server.
SecureCRT (Windows, macOS).
To use SSH keys in SecureCRT, you must specify the key in the “Connect” dialog box when connecting to a server. This can be done by following the following steps:
- Click on “Quick Connect” in the menu bar.
- Fill in the “Hostname” field with the name or IP address of the server you want to connect to.
- Click “Auth” in the left sidebar.
- Click “Browse” next to the “Private key file” field and select the key you want to use.
- Click “Connect” to connect to the server.
Bitvise SSH Client (Windows).
To use SSH keys in Bitvise SSH Client, you must specify the key in the “Login” dialog box when connecting to a server. This can be done by following the following steps:
- Fill in the “Hostname” field with the name or IP address of the server you want to log in to.
- Click on “Login” and select “Publickey” as the “Authentication method”.
- Click “…” next to the “Private key file” field and select the key you want to use.
- Click “Login” to connect to the server.
MobaXterm (Windows)
To use SSH keys in MobaXterm, you must specify the key in the “SSH Browser” window. This can be done by following the following steps:
- Open the “SSH Browser” window by clicking “Session” in the menu bar and then “SSH”.
- Click on the “Advanced SSH settings” button.
- Click on the “SSH keys” tab.
- Click “Import” to import the key you want to use.
- Click “OK” to save the changes.
- Connect to the server as you normally would, and MobaXterm will automatically select the correct key.
A summary of the article
Using SSH keys is a more secure way to connect to a server than using passwords. The process of generating and using SSH keys is not too complicated, and can be completed using most SSH clients. By following the steps described above, you can generate and use SSH keys for your favorite SSH client, be it OpenSSH, PuTTY, SecureCRT, Bitvise SSH Client, or MobaXterm.