key-based authorization with SSH”. Or simply “publickey authorization”. Or “unattended ssh login

Posted on 1:20 PM by Bharathvn

Here are the steps:

1. Create a public ssh key, if you haven’t one already.
Look at ~/.ssh. If you see a file named then you obviously already have a public key. If not, simply create one. ssh-keygen -t dsa should do the trick.
Please note that there are other types of keys, e.g. RSA instead of DSA. I simply recomend DSA, but keep that in mind if you run into errors.
2. Make sure your .ssh dir is 700:
chmod 700 ~/.ssh
3. Get your public ssh key on the server you want to login automatically.
A simple scp ~/.ssh/ is ok.
4. Append the contents of your public key to the ~/.ssh/authorized_keys and remove it.
Important: This must be done on the server you just copied your public key to. Otherwise you wouldn’t have had to copy it on your server.
Simply issue something like cat >> .ssh/authorized_keys while at your home directory.
5. Instead of steps 3 and 4, you can issue something like this:
cat ~/.ssh/ | ssh -l remoteuser 'cat >> ~/.ssh/authorized_keys'
6. Remove your public key from the home directory on the server.
7. Done!
You can now login:
ssh -l remoteuser or ssh without getting asked for a passw