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 to be used only once and not on a regular basis.
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 working with OpenSSH via the Terminal application, generate SSH keys manually by following these steps:
- 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 of the file in which 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 to be 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 machine via OpenSSH. However, you will need the Terminal application, which varies depending on your operating system. On Linux, search for ‘Terminal’ or press ‘CTRL+ALT+T’. For macOS, search for “Terminal” as well, and 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, add 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, so you will be asked if you wish to maintain the connection. You can type “Yes” and then press ENTER.
- Authentication is the next step in the connection process. Once you have added the SSH keys, you can connect to the VM either immediately or after entering the passphrase for your key pair.
If you haven’t added any SSH keys yet, you’ll 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.