Welcome, I'm Shantanu Tushar, currently pursuing B.E. in Computer Science And Engineering at B.M.S. College Of Engineering, Bangalore. You'll find here mostly, apart from my personal details, technical stuff that I am able to put on here. Please share your views and comments in the Feedback section.
Please note that all content here is the best to my knowledge, and I do not take responsibility for any direct/indirect loss caused by following the text herein.
How to use ssh keys to make password-less logins
I regularly connect to my father's Ubuntu PC using ssh to help or to transfer files through scp. I have been using ssh keys to make these logins password-less and I thought the method needs a blog post :)
Generally a user can have two keys - a private key and a public key which we generate using the following process and then copy the public key to the remote machine. Remember, don't give anyone your private key.
This process has to be followed on the machine which will be used to login to the remote machine. If both ways is desired, repeat same steps from the other way (i.e. on remote).
I describe the process,
- Use ssh-keygen to generate your RSA key (giving a passphrase is optional). The key will be generated and you'll be prompted for the location, the default being ~/.ssh/id_rsa
- Use ssh-copy-id remoteuser@remotehost to copy your public key ~/.ssh/id_rsa.pub to the remote's authorized_keys. You'll be asked to enter credentials for the remote machine.
- Now, whenever you login to the remote machine, it checks if your public key (which is offered by your client machine when connecting) exists in its authorized_keys file. If yes, you're allowed access.