LINUXMAKER, OpenSource, Tutorials

SSH login without password

The Secure Shell or SSH refers to both a network protocol and the appropriate programs that can be used to securely establish an encrypted network connection with a remote device.
One uses this method, if one wants to get on a remote command line so to speak on the local computer. This outputs the output of the remote console on the local console and passes the local keystrokes to the remote computer.

Since an administrator has to log on to other hosts remotely countless times per day, it is easier to work with if you do not have to enter the password every time, but the computer that sets up the connection authenticates itself with the key of the local user.

For this we create a key pair (until Debian "Jessie")

ssh-keygen -t dsa

or

ssh-keygen -t rsa

Starting with Debian "Stretch" it is recommended to stop using DSA-Keypairs, but to generate the secure ECDSA-Keypairs.

ssh-keygen -t  ECDSA

You will be asked for a password, but you can refrain, if you want to go the way without a password.
These keys are stored in the home directory under .ssh / id_ecdsa.pub, respectively .ssh / id_dsa.pub or .ssh / id_rsa.pub.

Now we can port it to the desired remote system:

ssh-copy-id -p PORT -i ~/.ssh/id_ecdsa.pub user@remote-system

That's the tool of choice. Should it not be available, then this procedure also works,

cat ~/.ssh/*.pub | ssh -p Port user@remote-system 'umask 077; cat >>.ssh/authorized_keys'

Afterwards, the ssh login on the remote system would have to be done without a password prompt.