Skip to content

Login with a key

SSH logging in using the RSA key - increases the security of user authentication with the server and significantly hinders the use of some forms of SSH attacks (e.g. bruteforce). It makes it difficult for unauthorized persons to access the server console.

Generating RSA keys on Windows

  1. Download and run the free application PuTTygen (from here ) for generating keys.
  2. Leave the default values (SSH-2 RSA, key length 2048 bits), click Generate.
  3. When the key is generated, move the mouse in the area designated by the program.
  4. In the next window, enter the security password for the generated keys twice.
  5. Go to Conversions and select Export OpenSSH key to save the private key for OpenSSH. If you need a private key for PuTTY, you can select Save private key to save the private key in PuTTY Private Key Files (*.ppk) format.
  6. The content of the window (after Public key for pasting into OpenSSH authorized_keys file:) save in the account to the file ~/.ssh/authorized_keys. If the file is missing, the path ~/.ssh/authorized_keys should be created.

Generate RSA keys on Linux/macOS systems

  1. Execute the command ssh-keygen -t rsa, it should show the following message: Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa):
  2. Do not change anything, press ENTER.
  3. Enter the security password for the generated keys twice: Your identification has been saved in ~/.ssh/id_rsa. Your public key has been saved in ~/.ssh/id_rsa.pub.
  4. Receiving the above message means that there are two keys, one private (located in ~/.ssh/id_rsa) and one public (located in ~/.ssh/id_rsa.pub) .

Login to the server from Windows

In the case of logging in from Windows, run PuTTy, go to the Connection tab, then Data. Enter the account login in the Auto login username field, then go to the SSH and Auth tabs and enter the path to our private key in the Private key file for authentication field. Save the settings by going back to Session and clicking Save.

Login to the server from a Unix system

Transfer the public key to the server with the command: ssh-copy-id -i ~/.ssh/id_rsa.pub LOGIN@SERVER

Then log in to the server with the command: ssh LOGIN@SERVER

See also