1.19. SSH 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:

Account keys are managed in the "Personal data" section on the "SSH keys" tab.

  1. Open your console (Windows command prompt, macOS terminal, or Linux terminal).
  2. Go to the .ssh directory:
    • Windows:
      cd %userprofile%\.ssh

      If 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 ~/.ssh

      If the directory does not exist, create it with the command:

      mkdir ~/.ssh
  3. Generate a key pair:
    ssh-keygen -t rsa -b 2048

    The 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 of id_rsa). With the default parameters, the keys will be saved in the .ssh subdirectory 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.
  4. Display the contents of the public key:
    • Windows:
      type %userprofile%\.ssh\id_rsa.pub
    • macOS and Linux:
      cat ~/.ssh/id_rsa.pub
  5. Copy the displayed public key content and add the key to your account.
  1. Download and install PuTTY.
  2. Generate a secret key in PuTTY format using the PuTTYgen utility:
    1. Run puttygen.exe from the PuTTY utility installation directory.
    2. Opposite "Generate a public/private key pair", click "Generate".
    3. Save the generated private key by clicking "Save private key".
    4. Copy the contents of the public key from the "Public key for pasting into OpenSSH authorized_keys file" field.
  3. Run PuTTY.
  4. Open the settings section "Connection → SSH → Auth".
  5. Next to the "Private key for Authentication" field, click "Browse" and select the generated private key file.
  6. Save the settings.
  7. 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".
  1. Open the "Personal data" section and switch to the "SSH keys" tab.
  2. Click "Add Key".
  3. Specify the key data and click "Add":
    1. In the "Name" field, enter any name for the key.
    2. 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.

Attention!

When you delete a key from your account, it is automatically unlinked from everywhere it was linked.
  1. Open the "Personal data" section and switch to the "SSH keys" tab.
  2. Delete the key from the "List of your keys" block.
Content

    (5)