Skip to main content

Create and place an SSH key on a cloud server

SSH keys can be used for secure server connection via the encrypted SSH protocol. This is a key pair: the private key remains on your local computer, while the public key is placed on the server.

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

You can use SSH keys of the types ed25519, rsa, ecdsa, and dsa. Learn more about SSH keys for users.

  1. Create an SSH key pair.

  2. Optional: add a public SSH key to the user profile.

  3. Place a public SSH key on a cloud server.

1. Create an SSH key pair

You can create SSH keys in two ways:

Create an SSH key pair via the OS

  1. Open the CLI.

  2. Generate an SSH key pair:

    ssh-keygen -t <key_type>

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

  3. A message will appear asking you to choose a directory to store the key pair—example for an RSA key:

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

    To keep 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 it, and press Enter:

    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
  5. Wait for the message stating 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. Display 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.

Create an SSH key pair via OpenStack CLI

The SSH key will only be available for the one service user, project, and pool for which you have configured authorization in the OpenStack API.

When generating SSH keys via OpenStack CLI, the public key is automatically added to the user profile.

  1. Open the OpenStack CLI.

  2. Generate an SSH key pair:

    openstack keypair create <key_name> --private-key <file_for_key>

    Specify:

    • <key_name> — key name;
    • <file_for_key> — the file where the private SSH key will be saved on the local computer.

2. Optional: add a public SSH key to the user profile

You can add a public SSH key to your profile or to another user's profile. Then you can place the key on the server during server creation or on an existing server.

The key will be available in all projects the user is added to.

If you generated the SSH key pair via OpenStack CLI, the public key was automatically added to your profile.

  1. In the control panel in the upper-right corner, open the menu (account number) and select Profile.

  2. Go to the Access section.

  3. Open the SSH keys tab.

  4. Click Add key.

  5. Enter the key name.

  6. Paste the public SSH key in OpenSSH format.

  7. Click Add.

3. Place a public SSH key on a cloud server

A public SSH key can be placed when creating a cloud server or on an existing server.

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

Public SSH keys can be placed on an existing server using a utility or manually.

The utility adds the public SSH key to the end of the ~/.ssh/authorized_keys file. The command used creates the directory and file if they do not already exist.

  1. Open the CLI on your local computer.

  2. Copy the public SSH key to the cloud server:

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

    Specify:

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

SSH keys for users

How to add a key to a user profile
  • For yourself: in the control panel in the upper-right corner, open the menu (account number) → Profile → the Access section → the SSH keys tab;
  • for another user: in the control panel in the top menu, click IAM → the Users or Service Users section → user page;
  • added automatically when creating SSH keys via OpenStack CLI (the openstack keypair create command);
  • via API;
  • via Terraform;
  • via selvpc CLI
How to place it on a cloud server when creating a server
  • Via OpenStack CLI (the openstack server create command);
  • via API;
  • via Terraform
Available for which usersFor one user of any type
Available in which projectsIn all projects the user is added to
Available in which pools
  • Available in all pools if added in the control panel in the AccountUsers section → tab with the required user type → user page;
  • available only in pools in which it was added via OpenStack CLI, API, Terraform, selvpc CLI
Where to view the key list
  • Your own: in the control panel in the upper-right corner, open the menu (account number) → Profile → the Access section → the SSH keys tab;
  • other users: in the control panel, click IAM in the top menu → Users or Service Users → user page;
  • via OpenStack CLI (the openstack keypair list command);
  • via API;
  • via Terraform;
  • via selvpc CLI