Before we can even create our Ubuntu server we need to generate what are called SSH keys which allow users connect to their servers remotely and securely, this is where you need to download and install the program Putty, once Putty is installed you need to open a program which came bundled with Putty called Putty Key Generator, this program allows you to generate a long private key which is what you’re going to be using to connect to your Ubuntu 18.04 server.
Once you’ve opened PuTTY Key Generator you’re going to be presented with the window below, you then simply need to click Generate the program will then ask you to randomly move your mouse in the key box which is used to generate your private SSH key.
Once the program has finished generating a key your screen will look as below.
You simply then need to click Save private key, you’ll be presented with a warning asking if you’re sure you want to save the key without a passphrase to connect it, I personally don’t set a passphrase though if you would prefer to add a layer of protection you simply need to type a phrase in the boxes above.
Using your key
So now that you have a private key that you can use to securely connect to your Ubuntu 18.04 sever it’s time to create the actual server you’re going to be using. Again for this I’m going to be using a provider called Hetzner you don’t have to use the same at myself though I recommend the follow providers due to previous experience, DigitalOcean, Linode, Vultr, OVH, RamNode, Scaleway.
While going through the configuration for server creation near the end just before you launch your server you should see an option for “SSH Key”, what we’re going to do here is go back to PuTTY and copy all the text from within the “Public key for pasting into OpenSSH authorized_keys file”, once you’ve done that simply paste the contents into your providers “Add an SSH key” window, for example with Hetzner the image below though this will vary between providers but should more or less be similar.
Once you click add the key should be saved to your account meaning you no longer have to re-add your public key each time you create a new server.
Connecting to your server
Now we’re going to use the Putty SSH client to connect to your server, simply open putty and copy paste your new cloud servers public IP address into the “Host Name or (IP address)” field, once you’ve done this you need to navigate to “SSH” through the categories on the left hand side, this should then reveal a few more options on which you then need to choose “Auth” on the bottom section “Authentication parameters” choose browse and select your private key that you generated at the very beginning of the tutorial, before you click open if you head back to “Session” at the top of categories on the left hand side you can save your connection configuration which means PuTTY will remember the IP address of your server and which key you want to use to connect.
Once you click open you’re going to be shown a security alert which is because you’ve not connected to this server before, though as you created the server a few moments ago it should be safe to ignore, once you’ve connected for the first time PuTTY should no longer display this warning.
Congratulations! You’ve now connected securely to your Ubuntu 18.04 instance!