How to connect to your virtual machine via SSH in Linux?

In this article, we will present two options to assure a successful connection via ssh:

  • Import the public key
  • Export the public key

Import the public key

To start off, we have to generate the most essential component to provide a harmless authorization among virtual machine and our personal computer.

Following the first point let’s open terminal and head to the directory where we would like to possess our keys stored.

Run a ssh-keygen command to create a public and private key.

Parameters explanation:

-t: provide information about the encryption algorithm

-f:  specify the keyfile name. (If we had left it by default we would have got id_rsa and id_rsa.pub)

During the process, you will be asked for entering a passphrase.

Key files have been created and are placed in ~/keys directory.

Copy the content of the Public key to your clipboard. It will be used in the next part.

Log in to your CreoDIAS account and move to Horizon Panel. Look at the navigation list appeared on the left of your screen. Enrol 

Project and next enrol nested sublist Compute.

Click on the “Key Pairs”.

You should be redirected to your Key Pairs list. We are interested in buttons placed above it.

Choose “Import Key Pair”

Name Key Pair Name and paste the content of the Public key into the blank field. After that confirm the applied changes.

Create a new virtual machine. During the initialization process remember to include “allow_ping_ssh_rdp” security group and freshly created Key Pair.

Focus on the “Actions” column for your instance and choose “Associate Floating IP”

Attach a floating IP to your private network interface. (It looks such as 192.168.0.x)

Move to the terminal on your computer. Be sure that you are in the directory where the ssh keys are stored.

Type in:

After all you should be connected to your virtual machine:

Export the public key

In the second scenario move to your Key Pairs panel and choose “Create Key Pair” instead.

Name the Key Pair Name and next copy private key to Clipboard.

Create a key file in any text editor:

Paste the content and save the changes.

Launch an instance as presented in the first option with included security groups and key pair. Remember to associate a floating IP to your private network interface.

Change the directory to the test.key localization and type in those commands:

As you may realize, it works in the same way.



Was this article helpful?