The best and most secure way to authenticate to your Linux server (which is also the default for most Openstack-based Linuximages) is to use SSH key pairs. This guide will help you get started with this from a windows computer using the PuTTY program (there is now a standard SSH client in Windows 10 in Powershell that can also be used similar to Linux and OSx).
Create your key pair
Start by logging in to your cloud portal and go to “SSH keys”. Here you choose the name of your key, and then click “Generate” if you want to create a new key pair (or copy your already saved key pair).
NOTE: If you are generating a new key pair, it is important that you save the private key (the lower one) as it cannot be recreated!
Then click “Save key” and the key is now ready to use when creating new instances.
Create an instance with the key pair
Go to “Instances” and create a new instance. Now your newly created key pair can be used under “SSH keys”. Select the key, and go ahead and create your instance. In the example below, we have created an Ubuntu 18.04 instance.
Use key-based login with Windows & Putty
Putty is a common tool for SSH connections on Windows machines. Here we go over how to use this to log in to your server.
Convert the key
On Linux / OSx / Windows 10 with OpenSSH you can use the PEM file that you saved with your private key directly, but to be able to use your key with Putty, you first need to convert it to the correct format. For this we use PuTTYgen (Download).
- Start PuTTYgen
- Click “Load”.
- Locate your private key file that you saved (you may need to choose to view all file types). Select the file and click “Open”. PuTTYgen has now loaded your key.
- You can now select a “passphrase” (an extra password for the key) if you want – which is recommended – and then select “Save private key” and save the key in a safe place.
- You are now ready and have a ready-made PuTTY-compatible key to use – now you can open PuTTY (download)
Log in to your instance
- In putty, enter the IP address of the server you just created and want to log in in the field “Host Name (or IP address)”.
- Then go to “Connection” -> “Data” and fill in “root” in the field “Auto-login username”.
- Then go to “Connection” -> “SSH” -> “Auth” and select “Browse” at the bottom to select private key. Find your private key and select it.
- Then click “Open” and the session against your server will be initiated with key-based authentication for the root user. If you have chosen a passphrase, the server will ask for it, in which case enter the password you chose in PuTTYgen, and then you should be logged in to your server.