Friday 18 February 2011

SSH login without password

Too often I have to login on different server over ssh in order to do my daily duties.
If you are using PuTTY on Windows you can pass your login credentials in command line. In such way you can create a shortcut and skip the login process.
ssh does not have such command line option, but you can achieve the same effect with few simple steps.



Create public and private keys by running ssh-keygen -t rsa at the local machine.
Login on the remote machine and create .ssh directory in the home: mkdir .ssh
On the local run:
cat .ssh/id_rsa.pub | ssh USERNAME@REMOTE_SERVER 'cat >> .ssh/authorized_keys'


Nex time you should be able to login without entering password, just by providing USERNAME

If you still have problems, try this from home on the remote machine:
chmod 700 .ssh
chmod 640 .ssh/authorized_keys


1 comment:

  1. Awesome, copmbined with ssh launcher this saves me hours of typing ports and password. Thanks )))

    ReplyDelete