passwordless SSH login

byo71's picture
Communications | Debian Support

need to run scripts on another server but dont want to have to include your passwords in the scripts?
Use RSA logins instead.
This uses a pre-generated set of public RSA keys to authenticate sessions rather than having to enter passwords.

On the machine you wish to log in from:

$ ssh-keygen -t rsa

make sure to leave the passphrase blank!

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@server

you will be prompted for the user's password to authenticate the key transfer.

This message will appear when the transfer is complete:

"
Now try logging into the machine, with "ssh 'username@server'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
"

Now you have passwordless login working! Now you can just:

$ ssh username@server

and you will be logged in without the remote system asking for a password.

Script away!

byo71's picture

now run a command remotely

$ ssh server uptime

Viola! The other machine's uptime is displayed.

$ ssh server uptime
14:52:57 up 8 days, 18:18, 1 user, load average: 0.00, 0.00, 0.00

Just to demonstrate the power of your new abilities.