Skip to main content

Adding keys to VMs

For security reasons, once you have created a ccloud³ VM on centron, you cannot add or change SSH keys via the control panel. However, there are several ways to do this via the command line. If you currently have SSH access to your ccloud³ VM, you can upload keys in several ways:

  • From your local computer using ssh-copy-id:

    This method is supported in many Linux distributions that include OpenSSH packages. It is recommended for its ease of use.

  • From your local computer by piping the key into the ~/.ssh/authorized_keys file on the ccloud³ VM:

    This method is a good option if you do not have ssh-copy-id available.

  • By connecting directly to your ccloud³ VM via SSH and manually adding the public key:

    This is necessary if you do not have password-based SSH access.

If you are currently unable to connect to your ccloud³ VM at all, use the recovery console to reset the root user password. Once you have logged in via the console, you can either add your key manually from the console or temporarily enable password-based authentication to add the key via SSH.

Local access via ssh-copy-id and password-based authentication

If you have password-based access to your ccloud³ VM, you can use ssh-copy-id to copy your SSH key from your local computer to your ccloud³ VM.

  • Command: ssh-copy-id use_your_username@203.0.113.0

    To specify a different key, use the -i flag: ssh-copy-id -i ~/path/to/key.pub use_your_username@203.0.113.0.

  • Confirmation of authenticity and entry of the password, followed by confirmation that the key has been added.

Local access via pipen in SSH with password-based authentication

If you do not have ssh-copy-id but do have password-based SSH access to your ccloud³ VM, you can add an SSH key to your ccloud³ VM by piping the contents of the key into the SSH command:

  • Command: cat ~/.ssh/id_rsa.pub | ssh username@203.0.113.0 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Manually from the ccloud³ VM

If you do not have password-based SSH access, you will need to add your public key manually to the remote server.

  • Viewing the key contents on the local computer: cat ~/.ssh/id_rsa.pub

  • Copying and pasting the key onto the ccloud³ VM.

    Command: echo "ssh-rsa EXAMPLEzaC1yc2E...GvaQ== username@203.0.113.0" >> ~/.ssh/authorized_keys

Ensure that the ~/.ssh directory and the authorized_keys file have the correct restricted permissions (700 for ~/.ssh and 600 for authorized_keys) so that you can log in without a password.