SSH keys for passwordless login

Generating a keypair on the client machine

On the client, create a new ssh key

ssh-keygen

NOTE: There are parameters you can add to the command above, like the type of key to generate. This guide keeps it simple though

You will be prompted for where to save the file. The default is fine (Press enter to accept the default):

Enter file in which to save the key (/home/myUsername/.ssh/id_keyType):

You will then be asked for a passphrase (password) for the key. This increases security as now someone with your private key (which should never happen!) will also need to know your passphrase for it to be useful. Either enter a passphrase, or press enter to omit a passphrase:

Enter Passphrase (empty for no passphrase):

Now you will have two files where you chose to save your key: id_keyType and id_keyType.pub. id_keyType is your private key - do not give this to anyone!! id_keyType.pub is your public key.

Getting your public key on the server

The server needs a copy of your public key, so that it can verify you when you try to log in using your private key.

Assuming that you can authenticate with the ssh server using password authentication, the following command will copy your public key to the server:

ssh-copy-id user@server

Done!

Test it!

You should now be able to ssh to the server without using your user password using the following command:

ssh user@server