Connect via SSH
When creating a VM, you can use SSH keys to access it. This allows you to access your VM securely and establish a secure connection.
Prerequisites
- Access to the centron Control Panel
Types of SSH keys
Default SSH keys: SSH keys intended for frequent use.
Ad hoc SSH keys: SSH keys that are intended for one-off use only and are not designed for frequent use.
Generating an SSH key
SSH keys can be generated and used on macOS or Linux provided that both OpenSSH and the ssh-keygen command-line tools are installed. OpenSSH is a collection of tools for establishing SSH connections to remote servers, whilst ssh-keygen is a utility for generating SSH keys.
If you are using OpenSSH via the Terminal application, follow these steps to generate SSH keys manually.
- Type the following command into the terminal window and press ENTER.
ssh-keygen
The key generation process is initiated by the command mentioned above. When you run this command, the ssh-keygen utility will prompt you to specify a location for the key.
- Accept the default save location by pressing the ENTER key, or enter the path to the file where you wish 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, the following prompt may appear. If you choose to overwrite the key, you will no longer be able to authenticate using the previously generated key.
/home/username/.ssh/id_rsa already exists.
Overwrite (y/n)?
-
Enter the passphrase used to encrypt the private key file on the hard drive. You can also press ENTER to accept the default setting (no passphrase). However, we recommend that you use a passphrase.
-
Enter your passphrase again. Once you have confirmed the passphrase, the public and private keys will be generated and saved to the specified location. The confirmation will then 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]-----+
You can copy the public key to the clipboard by running the following command:
pbcopy < ~/.ssh/id_rsa.pub
Connecting using an SSH key
You can connect to your virtual instance via OpenSSH. However, you will need the terminal application, which varies depending on the operating system.
For Linux: Search for ‘Terminal’ or press CTRL+ALT+T
For macOS: Find Terminal
For Windows: Search for Bash. If you do not have Bash installed, use PuTTY instead.
The following steps show you how to connect to your VM.
- Open the Terminal application and enter the SSH connection command shown below. After the @ symbol, enter the IP address of your VM instance. Then press ENTER.
ssh root@215.215.215.215
When you log in for the first time, the server will not be recognised on your local computer. You will be asked if you wish to maintain the connection. You can type “Yes” and press ENTER to confirm.
- Authentication is the next step in the connection process. Once you have added the SSH keys, you can connect to the VM immediately or after entering the passphrase for your key pair.
If you have not yet added any SSH keys, you will be asked for your password:
root@215.215.215.215's password:
- Once you have entered the password, press ENTER.
If the SSH key is configured correctly, use it to log in to the VM.