Hello there! In this short article I want to show you how to generate fresh ssh keys and copy them to your server for passwordless login. You’ll need a Linux machine to follow through.
First step is to generate the keys. I don’t advise to use a passphrase for the private key, you’ll be asked for it every time you login to the server, which is not ideally.
$ ssh-keygen -f ./id_rsa
$ ls
id_rsa id_rsa.pub
Here we have generated a private and a public key. Just keep them safe and don’t share with unauthorized persons!
Now the second step is to copy the public key to your server. Replace {user} and {host} with your machine credentials. When prompted, type your credential password for the user you supplied.
$ ssh-copy-id -i id_rsa.pub {user}@{host}
After this step is completed, it’s time to test the connection:
$ ssh -i id_rsa {user}@{host}
You should now be granted access without password. Please note that in this tutorial I saved the key separately but you can choose to save it to your home folder and thus to avoid using the -i switch. Hope it’s useful to you!
I use the SSH keys for passwordless login for connecting to my Raspberry PI!
Thanks for reading, I hope you found this article useful and interesting. If you have any suggestions don’t hesitate to contact me. If you found my content useful please consider a small donation. Any support is greatly appreciated! Cheers 😉