How to Auto-Login to a Linux Server Using Public Key

This is a manual version of ssh-copy-id command.
Let’s say that we are logging in to server named B from a local machine named A.
First off, generate authentication key pair without passphrase on the local machine A:

1ssh-keygen -t rsa

Now you got a public key of your local machine, of which path is:

1cd ~/.ssh
2cat id_rsa.pub

Grab the public key to append it to the server’s file named authorized_keys.
If the file doesn’t exist, create one on the server like so:

1cd ~
2mkdir .ssh
3touch authorized_keys

Congrats!
Now you can login to the server B without any credentials from the local machine A.
Happy networking! 😎

comments powered by Disqus