SSH keys is an excellent way to authenticate and grant access to your server from your personal computer. A SSH keypair is a pair of keys located in two files where one of them is public and the other one private, when you connect to your server the server will respond with the public key which is then compared to your private key located on your computer, that way it's safer than authentication with password where you send your password to the server without knowing who might be listening.
So how do we set this up then, well if you're a Windows user like me you can use a little program called puttygen. This is how it looks:
Now start by clicking on the Generate button, additionally you could change the key length from 2048 to 4096, it's slower but provides better security from brute force.
During generation, move your pointer over the field to generate some randomness
When the key is finished, change the comment field to the user name you'd like to login as, preferably admin. After that the public key is now seen in the big textbox at the top, copy it's content and paste it to this file on your VPS: /home/admin/.ssh/authorized_keys as a single line, save and close connection.
Next step is to go back to putty-gen, now you must click on Save private key to save your private key to your local computer. The final step is to test if everything works, what you do now is to open Putty or WinSCP to connect to your VPS but instead of password (skip that), you go to: Connection -> SSH -> Auth (putty), at the bottom of that page you'll see a browse button, click that and locate your private key file then save and connect.
You should now be logged in to your VPS without having to enter your password and your connection should be secured by your keys as verified by line 2 in your terminal log:
Hopefully you'll find this useful 😄