Skip to main content
Create and host an SSH key on a dedicated server
Last update:

Create and host an SSH key on a dedicated server

SSH keys can be used to securely server connections over the encrypted SSH protocol. This is a key pair: the private key is stored on the local computer and the public key is placed on the server.

For authorization on a dedicated Linux server, we recommend using SSH keys instead of login and password.

SSH keys of types ed25519, rsa, ecdsa, and dsa can be used.

  1. Create an SSH key pair.

  2. Optional: Add the public SSH key to the SSH key repository.

  3. Place a public SSH key on the server:

Create SSH keys

  1. Open the CLI.

  2. Generate a pair of SSH keys:

    ssh-keygen -t <key_type>

    Specify <key_type> — SSH key type: еd25519, rsa, ecdsa or dsa

  3. A message will appear asking you to select a directory to store the key pair — example for rsa key:

    Enter file in which to save the key (~/.ssh/id_rsa):

    To leave the default directory for storing keys, click Enter. If you want to select a different directory, enter it in the format /path/to/id_rsa and press Enter.

  4. Optional: enter a passphrase for additional protection, repeat the passphrase and press Enter. The passphrase will not be displayed on the command line:

    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
  5. Wait for the message that the keys have been generated. Two files will be created: id_rsa (private key) and id_rsa.pub (public key). The key fingerprint and its image will appear in the terminal:

    Your identification has been saved in ~/.ssh/id_rsa
    Your public key has been saved in ~/.ssh/id_rsa.pub
    The key fingerprint is:
    The key's randomart image is:
  6. Output the public SSH key:

    cat <path>

    Specify <path> — the full path to the public key you specified in step 3, for example ~/.ssh/id_rsa.pub.

Optional: add a public SSH key to the SSH key repository

A public SSH key can be added to the SSH key repository and placed on the server automatically at ordering a new server or when reinstalling the OS for an existing server.

  1. In the control panel go to Servers and hardwareSSH keys.
  2. Click Add an SSH key.
  3. Enter the name of the key.
  4. Insert a public SSH key.
  5. Click Add.

Place an SSH key on a dedicated server

Placing a public SSH key is possible:

Place SSH key on a dedicated server with OS reinstallation

  1. In the control panels go to Servers and hardwareServers.

  2. Open the tab Server list.

  3. Open the server page → tab Operating system.

  4. Click Change the OS configuration.

  5. In the field SSH key add an SSH key:

    • check the checkbox for the SSH key you want to use. added to the vault for SSH keys;
    • or press Add a new key. Enter a key name and paste the public SSH key you created earlier. Click Add. Key will be added to the storage for SSH keys.
  6. Click Set.

Place SSH key on a dedicated server without reinstalling the OS

Without reinstalling the OS, the public SSH key can only be placed on the server by copying the key from the local computer. Command ssh-copy-id adds the public SSH key to the end of the file ~/.ssh/authorized_keys. The command creates a directory and a file if they have not already been created.

  1. Open the CLI on the local computer.

  2. Copy the public SSH key to the server:

    ssh-copy-id -i <path> <username>@<ip_address>

    Specify:

    • <path> — the full path to the public key on the local computer, e.g. ~/.ssh/id_rsa.pub;
    • <username> — username;
    • <ip_address> — the public IP address of the server.
  3. Enter the user's password.