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,

Steps-

  1. 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
  2. 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.
  3. 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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s