mkormendy
11/8/2015 - 5:35 PM

SSH Autologin

SSH Autologin

Step 1

Create a password-less ssh rsa key:

ssh-keygen -b 2048 -f ~/.ssh/id_rsa -P ''

Step 2

Copy the key to your remote host (drop the port if not needed):

ssh-copy-id '-p 2222 username@remote.host'

Sometimes this doesn't work, so use the following command instead:

cat ~/.ssh/id_rsa.pub | ssh username@remote.host -p 2222 'cat - >> ~/.ssh/authorized_keys2'

Enter your password to login to the server if needed.

Step 3

Now you can log into the server without being forced to enter a password:

ssh user@remote.host -p 2222