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

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

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. Read more about SSH keys for the user.

  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 a pair of SSH keys using OS tools

  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 — an example for an 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:

    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.

Create an SSH key pair through the OpenStack CLI

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

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

  1. Open the OpenStack CLI.

  2. Generate a pair of SSH keys:

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

    Specify:

    • <key_name> — key name;
    • <file_for_key> — file that will store the private SSH key 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 server the key at creation or on an existing server.

The key will be available in all projects to which the user has been added.

If you generated an SSH key pair through the OpenStack CLI, the public key was automatically added to the user profile.

  1. В control panels from the top menu, press Products and select Cloud servers.

  2. Go to the section Access.

  3. Open the tab SSH keys.

  4. Click Add an SSH key.

  5. Enter the name of the key.

  6. Insert a public SSH key in OpenSSH format.

  7. Click Add key.

3. Host a public SSH key on a cloud server

You can place a public SSH key by cloud server creation or on an existing server.

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

You can place public SSH keys on an existing server using a utility or manually.

The utility adds the public SSH key to the end of the file ~/.ssh/authorized_keys. The command used creates the directory and 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 <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.

SSH keys for the user

How add the key to the user profile
  • Self: in the control panel, in the top menu, press Account → section Access → tab SSH keys;
  • to another user: in the control panel, in the top menu, press Account → section Users or Service users → user page;
  • will be added automatically when creating SSH keys through the OpenStack CLI (command openstack keypair create);
  • through the API;
  • through Terraform
How to host on a cloud server when server creation
  • Through the OpenStack CLI (openstack server create command);
  • through the API;
  • through Terraform
For which users is it availableFor one user of any type
In which projects is it availableIn all projects to which a user has been added
What pools are available in
  • Available in all pools if added in the control panel: Account → section Users or Service users → user page;
  • is available only in pools to which it was added via OpenStack CLI, API, Terraform
Where can I see the list of keys
  • Your own: in the control panel in the top menu, click Account → section Access → tab SSH keys;
  • of other users: in the control panel in the top menu, click Account → section Users or Service users → user page;
  • through the OpenStack CLI (command openstack keypair list);
  • through the API;
  • through Terraform