How to connect to your virtual machine via SSH in Linux?
Two options to assure a succesful connection via ssh:
- through import the public key
- through export 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 directory where we would like to possess our keys stored.
cd ~ mkdir keys cd keys
Run a ssh-keygen command to create a public and private key.
ssh-keygen -t rsa -f cloud.key
-t : provide an information about 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.
Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): [Enter] Enter same passphrase again: [Enter] Your identification has been saved in cloud.key. Your public key has been saved in cloud.key.pub. The key fingerprint is: SHA256:MXp8AyLjtNzIhPs5FYfe7eFo/ECwIzLpLWOBQXHmv/4 [username@machine]
Keys 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.
More about key generations and converting them to Putty Format:
- Generating a SSH keypair in Linux
- How to convert Linux OpenSSH Key to putty format?
- How to create SSH Key Pair in Windows?
Log in to your CreoDIAS account and move to Horizon Panel. Have a look at navigation list appeared on the left of your screen. Enroll Project and next enroll 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”
Set 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.
ssh -i cloud.key eouser@[floating ip] example: ssh -i cloud.key firstname.lastname@example.org Are you sure you want to continue connecting (yes/no)? [yes]
After all you should be connected to your virtual machine:
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 safe 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:
chmod 600 test.key (You may encounter some privileges problems. Apply read and write options only for the user to overcome this setup) ssh -i test.key eouser@[floating ip]
As you may realise, it works in the same way.