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

Create and host an SSH key on a cloud 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.

We recommend using SSH keys instead of login and password to authenticate to the cloud server.

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

  1. Create an SSH key pair.

  2. Optional: add public SSH key to cloud platform.

    The way a key is added to the cloud platform affects its availability in projects, pools, and to users, as well as the way it is placed on the server when created. See the SSH-keys-for-project-and-service-user table for more information on key differences.

  3. Place a public SSH key on a cloud server: when creating a server or on an existing 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: ed25519, 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, 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 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 <~/.ssh/id_rsa.pub>

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

  7. Optional: add a public SSH key to the cloud platform, place a public SSH key when creating a server, or on an existing server.

Add a public SSH key to the cloud platform

A public SSH key can be added to the cloud platform and then placed when creating a server.

The way a key is added to the cloud platform affects its availability in projects, pools, and to users, as well as the way it is placed on the server when created. See table for more information on key differences.

The key will only be available in one project, for all users.

  1. In Control Panel, go to Cloud PlatformAccess.
  2. Open the SSH keys tab.
  3. Click Add SSH Key.
  4. Enter the name of the key.
  5. Insert a public SSH key in OpenSSH format.
  6. Click Add Key.

Place a public SSH key on a cloud server when creating a server

Only SSH keys for project are available.

  1. In Control Panel, go to Cloud PlatformServers.

  2. Click Create Server.

  3. In the Access block, add an SSH key to the server:

    • select the SSH key that you added to the cloud platform — you can select only SSH keys for the project;
    • or add a new SSH key that you created earlier. The key will be added to the cloud platform and will only be available for the project.
  4. Select the rest of the server settings — see the Create Cloud Server instructions for details.

  5. Press Create.

Host a public SSH key on an existing cloud server

To access the cloud server via SSH, you need to add a public SSH key to the ~/.ssh/authorized_keys file on the server. You can add multiple keys, for example, if you need access for multiple users.

Public SSH keys can be placed in two ways:

Copy a public SSH key from a local computer using ssh-copy-id

The ssh-copy-id command adds the public SSH key to the end of the ~/.ssh/authorized_keys file. 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 cloud server:

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

    Specify:

    • <~/.ssh/id_rsa.pub> 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.

Place a public SSH key on the server manually

  1. Open the public SSH key file on the local computer:

    cat ~/.ssh/id_rsa.pub
  2. Copy the value of the public SSH key.

  3. Connect to server.

  4. Navigate to the .ssh directory:

    cd .ssh
  5. Create an authorized_keys file in the .ssh folder:

    touch authorized_keys
  6. Add a public SSH key to the authorized_keys file:

    echo <public_ssh_key> >> ~/.ssh/authorized_keys

    Specify <public_ssh_key>, which is the public SSH key you copied in step 2. It starts with ssh-rsa.

  7. Configure access rights:

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys

SSH keys for project and service user

A public SSH key can be added to the cloud platform:

SSH key for projectSSH key for service user
How to add a key to the cloud platformIn the control panel under Cloud PlatformAccess
  • In the control panel under User Management → tab Service Users → user page;
  • will be added automatically when SSH keys are created via OpenStack CLI (openstack keypair create command);
  • via API;
  • via Terraform;
  • via selvpc CLI
How to deploy to a cloud server when creating a serverIn the Control Panel
  • Via OpenStack CLI (openstack server create command);
  • via API;
  • via Terraform
For which users is availableFor all project usersFor one service user with the roles Project Administrator or Project Supervisor
In which projects is availableIn one projectIn all projects to which the service user has been added
In which pools is availableOnly in the pool to which it has been added
  • Available in all pools, if it has been added in the control panel under Available in all pools, if it has been added in the control panel under
  • Available only in pools to which it was added via OpenStack CLI, API, Terraform, selvpc CLI
Where to see the list of keysIn the control panel under Cloud PlatformAccess
  • In the control panel under User Management → tab Service Users → user page;
  • via OpenStack CLI (openstack keypair list command);
  • via API;
  • via Terraform;
  • via selvpc CLI