1.19. SSH keys
About keys
Keys allow you to connect to servers via SSH or SFTP without entering a password.
To set up SSH key authentication, you need to generate a key pair, add the public key to your account, and link it to the desired service:
- VPS — when reinstalling the OS.
- Dedicated — when reinstalling the OS.
Account keys are managed in the "Personal data" section on the "SSH keys" tab.
Generate key pair
Console
- Open your console (Windows command prompt, macOS terminal, or Linux terminal).
- Go to the
.sshdirectory:- Windows:
cd %userprofile%\.sshIf the directory does not exist and the error "The system cannot find the path specified" occurs, create it with the command:
mkdir %userprofile%\.ssh - macOS and Linux:
cd ~/.sshIf the directory does not exist, create it with the command:
mkdir ~/.ssh
- Generate a key pair:
ssh-keygen -t rsa -b 2048The program will prompt you to specify a file name for saving the keys and ask you to enter a passphrase. Press Enter to use the default settings and the standard file name
id_rsa(if you specify your own file name, use it in all subsequent commands instead ofid_rsa). With the default parameters, the keys will be saved in the.sshsubdirectory of the user's home directory. There will be two files:id_rsa— private key,id_rsa.pub— public key.If you get the error "'ssh' is not recognized as an internal or external command, operable program or batch file", you need to enable OpenSSH in Windows. - Display the contents of the public key:
- Windows:
type %userprofile%\.ssh\id_rsa.pub - macOS and Linux:
cat ~/.ssh/id_rsa.pub
- Copy the displayed public key content and add the key to your account.
PuTTY
- Download and install PuTTY.
- Generate a secret key in PuTTY format using the PuTTYgen utility:
- Run
puttygen.exefrom the PuTTY utility installation directory. - Opposite "Generate a public/private key pair", click "Generate".
- Save the generated private key by clicking "Save private key".
- Copy the contents of the public key from the "Public key for pasting into OpenSSH authorized_keys file" field.
- Run PuTTY.
- Open the settings section "Connection → SSH → Auth".
- Next to the "Private key for Authentication" field, click "Browse" and select the generated private key file.
- Save the settings.
- Copy the displayed public key content and add the key to your account.
Saving private keys in PEM format
The PuTTYgen utility saves the private key in PPK format by default. To save it in PEM format, in the main menu, click "Conversions → Export OpenSSH key".Keys in account
Add
- Open the "Personal data" section and switch to the "SSH keys" tab.
- Click "Add Key".
- Specify the key data and click "Add":
- In the "Name" field, enter any name for the key.
- Paste the copied public key content.
The added key will appear in the "List of your keys" block and can be linked to available services.
Delete
Attention!
When you delete a key from your account, it is automatically unlinked from everywhere it was linked.- Open the "Personal data" section and switch to the "SSH keys" tab.
- Delete the key from the "List of your keys" block.