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 connect to server via the encrypted SSH protocol. This is a key pair: the private key is stored on the local computer and the public key is hosted on the server.

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

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

  1. Create SSH key pair.
  2. Optional: add public SSH key to SSH key repository.
  3. Place a public SSH key on the server: c OS reinstallation or without OS reinstallation.

Create SSH keys

  1. Open the CLI.

  2. Generate a pair of SSH keys:

    ssh-keygen -t rsa
  3. A message will appear asking you to select a directory to store the key pair:

    Enter file in which to save the key (</home/user/.ssh/id_rsa>):

    To leave the default directory for storing keys, press 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 security, repeat the passphrase and press Enter:

    Enter passphrase (empty for no passphrase):
    Enter the same passphrase again:
  5. Wait for a message that the keys have been generated. Two files will be created: id_rsa (private key) and (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/
    The key fingerprint is:
    The key's randomart image is:
  6. Print and save the public SSH key:

    cat <~/.ssh/>

    Specify <~/.ssh/>, which is the full path to the public key that you specified in step 3.

Add a public SSH key to the repository for SSH keys

The key added to the storage for SSH keys can be placed on the server automatically only when the OS is reinstalled.

  1. In Control Panel, go to Servers and colocationSSH keys.
  2. Click Add SSH Key.
  3. Enter the name of the key.
  4. Insert a public SSH key.
  5. Click Add Key.

Place SSH key on dedicated server with OS reinstallation

  1. In Control Panel, go to Servers and colocation.

  2. Open the server page → Operating System tab.

  3. Click Change OS Configuration

  4. In the SSH key field, add the SSH key:

    • select the SSH key that you added to the SSH key repository;
    • or add a new SSH key that you created earlier. The key will be added to the storage for SSH keys.
  5. Click Set.

Place SSH key on dedicated server without OS reinstallation

Without reinstalling the OS, the public SSH key can only be placed on the server by copying the key from the local computer.

  1. Open the CLI.

  2. Copy the public SSH key to the server:

    ssh-copy-id -i <~/.ssh/> <username>@<ip_address>


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