Connect via SSH

When creating storages based on IONOS Linux images, you can inject SSH keys into your VM. This lets you access your VM safely and allows for secure communication. SSH keys that you intend to use more often can be saved in the DCD's SSH Key Manager.

Types of SSH keys

Default SSH keys: SSH keys that you intend to use often and mark them as such in the SSH Key Manager. Default SSH keys are preselected when you configure storage devices. You can specify which SSH keys are actually to be used before provisioning and deselecting the preselected standard keys in favor of another SSH key.

Ad-hoc SSH keys: SSH keys that you only use once and don't intend to save in the SSH Key Manager for later re-use.

Generating an SSH key

SSH keys can be generated and used on macOS or Linux if both OpenSSH and the ssh-keygen command-line tools are installed. OpenSSH is a collection of tools for establishing SSH connections to remote servers, while ssh-keygen is a utility for generating SSH keys.

Manually generate SSH keys when working with OpenSSH via the Terminal application by following the steps below.

1. Enter the following command below into the Terminal window and press ENTER.

ssh-keygen

The key generation process is initiated by the command above. When you run this command, the ssh-keygen utility prompts you for a location to save the key.

2. Accept the default location by pressing the ENTER key, or enter the path to the file where you want to save the key /home/username/.ssh/id_rsa.

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

If you have previously generated a key pair, you may see the following prompt below. If you choose to overwrite the key, you will no longer authenticate with the previous key that was generated.

/home/username/.ssh/id_rsa already exists.
Overwrite (y/n)?

3. Enter the passphrase that will be used to encrypt the private key file on the disk. You can also press ENTER to accept the default (no passphrase). However, we recommend that you use a passphrase.

4. Enter your passphrase once more.

After you confirm the passphrase, the public and private keys are generated and saved in the specified location. Thus, the confirmation will look like this:

Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:AcP/ieiAOoD7MjrKepXks/qHAhrRasGOysiaIR94Quk username@mb01739.local
The key's randomart image is:
+---[RSA 3072]----+
|     .o          |
|      .o         |
|..     ..        |
|.oo .   ..       |
|+=.+ . .So .     |
|X+. * . . o      |
|&Eo. *           |
|&Oo.o o          |
|@O++..           |
+----[SHA256]-----+

The public key is saved to the file id_rsa.pub which will be the key you upload to your DCD account. Your private key is saved to the id_rsa file in the .ssh directory and is used to verify that the public key you use belongs to the same DCD account.

You can copy the public key to your clipboard by running the following command:

 pbcopy < ~/.ssh/id_rsa.pub

Storing SSH keys

In the SSH Key Manager of the DCD, you can save and manage up to 100 public SSH keys for the setup of SSH accesses. This saves you from having to repeatedly copy and paste the public part of an SSH key from an external source.

1. To open the SSH Key Manager, go to Menu > MANAGER resources > SSH Key Manager.

2. In the SSH Key Manager, select + Add Key.

3. Enter a Name and click Add.

4. Copy and paste the public key to the SSH key field. Alternatively, you may upload it via Select key file. Please ensure the SSH keys you enter are valid. The DCD does not validate syntax or format.

5. (Optional) Activate the Default checkbox to have the SSH key automatically pre-selected when SSH access is configured.

6. Click Save to store the key.

The SSH key is stored in the SSH Key Manager and can be used for the configuration of SSH accesses.

Deleting an SSH key in the SSH Key Manager

To delete an existing SSH key, select the SSH key from the list and click Delete Key.

The SSH key is removed from the SSH Key Manager.

Connecting via OpenSSH

You can connect to your virtual instance via OpenSSH. Still, you will need the terminal application, which varies depending on your operating system. For:

  • Linux: Search Terminal or press CTRL+ALT+T

  • macOS: Search Terminal

  • Windows: Search Bash. If you don’t have Bash installed, use PuTTY instead.

The steps below will show you how to connect to your VM.

1. Open the Terminal application and enter the SSH connection command below. After the @, add the IP address of your VM instance. Then press ENTER.

ssh root@85.215.230.154

When you log in for the first time, the server isn't recognized on your local machine, so you'll be asked if you're sure you want to keep connecting. You can type yes and then press ENTER.

2. Authentication is the next step in the connection process. If you've added the SSH keys, you'll be able to connect to the VM immediately or after entering your key pair's passphrase.

If you haven't already added SSH keys, you'll be asked for your password:

root@85.215.230.154's password:

3. Once you’ve entered the password, press ENTER.

If the SSH key is configured correctly, this will log you into VM.

Last updated