Configuring password-less SSH

Posted on Jul 14, 2024

Password-less SSH relies on creating private and public keys that are used when logging in via SSH.

Last time I was doing this it was a convoluted process of generating keys, copying them to the remote machine, and possibly also some installation.

I don’t know if this changed or I didn’t find the correct instructions last time, but it is very trivial.

The pair is generated on the client computer. The public key is then added to the host, which will use the public key to authenticate you. Only the private key can create a signage that can be verified using the public key.

The process is only three short steps.

# 1. Generate pair
ssh-keygen

# 2. Add private key to client
ssh-add ~/.ssh/<KEY>  

# 3. Add public key to host
ssh-copy-id -p <PORT> -i ~/.ssh/<KEY> <USER>@<IP-OR-FQDN> # A

Now you can verify that everything works.

Tip! File name

Save the key with a name that matches your server’s name. That will make it easier to know what the key is used for. Note that you will need to specify the full path to ~/.ssh.