SSH key connection to VM

SSH key connection to Virtual Machine (VM)

When connecting to Linux VM, please choose your OS type for instructions

Generate OpenSSH key on MacOS or Linux

SSH is used to gain secure remote access to a remote system. Access is gained using a key. You have a private key file that must remain on your host and a public key file (.pub) that is not secret and is copied to the remote system to enable your private key to be used for access. You must provide us with the public key (.pub) if you want to use key authentication.

The standard OpenSSH toolset includes the ssh-keygen utility for generating key pairs. Run it on your local computer to generate a 2048-bit RSA key pair, which is fine for most uses.

ssh-keygen

The utility prompts you to select a location for the keys. By default, the keys are stored in the ~/.ssh directory with the filenames id_rsa for the private key and id_rsa.pub for the public key. Using the default locations allows your SSH client to automatically find your SSH keys when authenticating, so we recommend accepting them by pressing ENTER.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:n5atjy1iEhEH+TK/SL73x1YDg0qfmsdVoxhfRUKphyU user@hostname
The key's randomart image is:
+---[RSA 3072]----+
|      .o     .oo.|
|      o .   E o..|
|       +   . = . |
|      + o o = =  |
|       *So = B . |
|      o o.+++ o  |
|     o o ==o.. . |
|      + B.+++    |
|      .= ++=o    |
+----[SHA256]-----+

Add public key to myDEAC

In order to get a public key, enter cat.

cat ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCloXnzRVi2LQVzJds3xqrmBQPOt8HOKSA8cu+CwtNd8VIfyZt597l9CiFW6eLT4lJHn66Y3nbL1RjlnVQkkav5oD4LsLrB/BTbUtYwdGJRVhy8aRKNjmnFWGkhSxBART0jCbytZPA27ijrDGPJaijW3krPyk11N6byhLqaHaJR5UzSWyr3QDhJRRSBhChYE3VaW/T3pi+IGOxT2kufFn0HNoYXnaQ1rhhmrGX1C3kxO5CLHTPPO00X0+/rB3jZqXZtqme13rPwCghCyysd5w5vojMbd8dBewSl6EjlUj9F6iyQ0CiG2nUzC0aSLgErhmdHN8ecsG03EieSzG26j7fw3LAUT1jKlbGMxLaG/bNfUnMCntEvIvWckj6nnhrW/P0VXKukpjjZiMr+imdud03ghQgrIdXIf1MBcpkKWNpZPaNPnKhObu2RiBB8zcYXIlCoj9UmLlV2AjW82oJ5proE5njXLF1CTBLayYuseU3A079zZ/4Hbx+WBX+ct+Mltqc= user@hostname

Copy the id_rsa.pub public key content to the clipboard, and follow the steps below:

  1. Click the circle (user) in the upper right corner and select SSH keys.
  2. Click Add SSH key and paste it into the SSH key section.
  3. Enter a name for the SSH key and click Add SSH key.
  4. The key is saved.

Connect to the VM from your local computer

Open a terminal and run the command:

ssh root@<IP_address_of_VM>

Windows connect to Linux VM using PuTTY

To generate an SSH key on Windows, you will need to install PuTTY, both versions. PuTTY is a client for various remote access protocols, including SSH.

You can download PuTTY here. Once you have downloaded the file putty-64bit-0.xx-installer.msi (“Windows Installer”), install it on your local computer following the installer instructions.

Once the programs are installed, you can open PuTTYgen from the Start menu or by pressing Windows + R and typing:

puttygen

Then select ECDSA at the bottom and click Generate. Once the key has been generated, you’ll see the public key in a text box. Copy the generated key to the clipboard. To add the key to your myDEAC profile, follow the steps below:

  1. Click on the circle (Users) in the top right corner and select SSH keys.
  2. Click Add SSH key and Paste key here.
  3. Enter your name and click Add SSH key.
  4. The key will be saved.

When you’re done, click the Save Private Key button and choose a safe place to save the key. Your key can have any name you choose, along with any extension .PPK has automatically applied.

Use Putty:

  1. Open PuTTY.
  2. Add VM IP address in Session » Host Name(IP Address).
  3. Add Saved Sessions name.
  4. Go to Connection » Data » Auto-login.
  5. Add root username.
  6. Go to Connection » SSH » Auth » Credentials.
  7. In “Private key file for authentication”, click Browse and select your saved .ppk file with the key.
  8. Go back to the Session section.
  9. Click Save.
  10. And finally click Open.