There are the specific cases where typing the same password over and over again gets cumbersome, or those odd instances where typing a password isn’t even possible (due to automated scripts and processes).

These are the cases where password-less login – also known by the correct name: public-key authentication – is the solution. The procedure is simple and it involves creating a private/public key pair on the source machine and transferring the public key to the target machine.

On the source machine (the one that will be transferring files to the target):

This will generate a new key fingerprint (skip entering a passphrase):

Still on the source server, run
ssh-copy-id user@targetserver
or if the target server is running SSH on a custom port number
ssh-copy-id "user@targetserver -p 123"

This step will copy the key to the target system. You will be asked to login using the password one more time. Once this step is done you will be able to automatically login when SSH-ing from the source server to the target server.

The procedure can then be run in reverse (from the target machine) if you wish bidirectional public-key authentication.

If you later need to remove this type of authentication, edit
and delete the necessary lines.

Leave a Reply