1.19. SSH Keys
About keys
Keys allow you to connect to servers via SSH or SFTP without entering a password.
To configure SSH key authentication, you need generate a pair of keys, add the public key in the account and link it to the desired service:
- VPS — at reinstalling the OS.
- Dedicated — when reinstalling the OS.
Account keys are managed in the section "Personal data → SSH keys".
Generating a key pair
Through the console
- Openup Windows command line, macOS terminal or Linux terminal.
- Go to the directory
.ssh
:- On Windows:
cd %userprofile%\.ssh
If the directory does not exist and an error is returned "The system cannot find the path specified.", then create it with the command:
mkdir %userprofile%\.ssh
- On macOS and Linux:
cd ~/.ssh
If the directory does not exist, create it with the command:
mkdir ~/.ssh
- Generate a key pair:
ssh-keygen -t rsa -b 2048
The program will ask you to specify a file name for saving keys and ask you to enter a secret phrase. Click on Enterto use the default options and the default filename
id_rsa
(if you provide your own filename, use it in all subsequent commands instead ofid_rsa
). With default parameters, the keys will be saved in a subdirectory.ssh
the user's home directory. These will be two files:id_rsa
— private key,id_rsa.pub
- public key.
Note If an error returns "'ssh' is not recognized as an internal or external command, operable program or batch file."then you need to enable OpenSSH on Windows. - Print the contents of the public key:
- On Windows:
type %userprofile%\.ssh\id_rsa.pub
- On macOS and Linux:
cat ~/.ssh/id_rsa.pub
- Copy the displayed public key content and add the key in the account.
With PuTTY
- Download and install PuTTY.
- Generate a private key in PuTTY format using the PuTTYgen utility:
- Run puttygen.exe from the installed PuTTY directory.
- Against "Generate a public/private key pair" click "Generate".
- Save the generated private key by clicking "Save private key".
- Copy the content of the public key from the field "Public key for pasting into OpenSSH authorized_keys file".
- Start PuTTY.
- Open the settings section "Connection → SSH → Auth".
- Near the field "Private key for Authentification" click "Browse" and select the generated private key file.
- Save the settings.
- Copy the displayed public key content and add the key in the account.
Saving a private key in PEM format
The PuTTYgen utility saves the private key in PPK format by default. To save in PEM format, in the main menu, press "Conversions → Export OpenSSH key".Account Keys
Adding
- Open the section "Personal data → SSH keys".
- Click "Add to".
- Enter the key details and click "Add to":
- In field "Name" specify an arbitrary name for the key.
- Paste the copied content of the public key.
The added key will appear in the block "Added keys" and it can be tied to available services.
Deleting
Attention!
When a key is removed from an account, it is automatically unbound wherever it was bound.- Untie key from all hosting accounts where it was linked.
- Open the section "Personal data → SSH keys".
- Remove the key from the block "Added keys".