Login with a key
Warning
THIS PAGE HAS BEEN TRANSLATED AUTOMATICALLY - MAY CONTAIN INCORRECT OR OUTDATED INFORMATION.
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
- Download and run the free application
PuTTygen
(from here) for generating keys. - Leave the default values (
SSH-2 RSA
, key length2048 bits
), clickGenerate
. - When the key is generated, move the mouse in the area designated by the program.
- In the next window, enter the security password for the generated keys twice.
- Go to
Conversions
and selectExport OpenSSH key
to save the private key for OpenSSH. If you need a private key for PuTTY, you can selectSave private key
to save the private key inPuTTY Private Key Files (*.ppk)
format. - The content of the window (after
Public key for pasting into OpenSSH authorized_keys file:
) is saved 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
- We execute the command
ssh-keygen -t rsa
, we should get the following message:Generating public/private rsa key pair. Enter file in which to save the key (~/.ssh/id_rsa):
- We do not change anything, press
ENTER
. - 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.
- If we received the above message, it 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
. We 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 whole thing by going back to Session
and clicking Save
.
Login to the server from a Unix system
We transfer the public key to the server with the command:
ssh-copy-id -i ~/.ssh/id_rsa.pub LOGIN@SERVER
Then we log in to the server with the command:
ssh LOGIN@SERVER