How to Setup Passwordless SSH

From ReduxWiki

Jump to: navigation, search
Security dictates strong, difficult to memorize passwords, in turn an ability to remote authenticate without having to type in a password.

SSH allows such a process via ssh private/public key authentication. This subject can become moderately complicated, here is a short synopsis on the process assuming you would like to login from localhost to Network Redux without a password.

On your local machine type:

localhost$ ssh-keygen -t dsa

Accept the default directory and blank password (unless you wish otherwise).

Two files are now created in ".ssh" -- "id_dsa" and "id_dsa.pub". These are your private and public keys (respectively).

Using cPanel or shell create a new directory called ".ssh" and upload your new private key to there. For example:

networkredux$ mkdir ~/.ssh
localhost$ scp .ssh/id_dsa.pub username@yourdomain.com:~/.ssh

Add the new key to your keychain:

networkredux$ cd ~/.ssh
networkredux$ cat id_dsa.pub >> authorized_keys
networkredux$ rm id_dsa.pub

Next we set the permissions so that nobody can read your keychain.

networkredux$ chmod 700 ~/.ssh
networkredux$ chmod 600 ~/.ssh/authorized_keys
localhost$ chmod 700 ~/.ssh
localhost$ chmod 600 ~/.ssh/id_dsa*

You can reuse your public key on as many shell servers as you will be connecting to.

NOTE: If you use the above method, machines may be susceptible to compromise if any one of them is accessible by other users with privileges sufficient to read your ~/.ssh directory, where your private DSA key is stored. In other words, if you do not have exclusive root privileges on the local box mentioned above, you have opened the door to other individuals using your automatic login to gain access to the remote system (and anywhere else you’ve coped your public key), even if they should not have such privileges. You may wish to consider using ssh-agent instead.



Image:Tip.png Back to How To Documents
Personal tools