Password-less SSH Login
May 8, 2006
On occasion I have the need to establish trust relationships between Unix boxes so that I can script file transfers. In short, here’s how you leverage SSH to do that. Using the example of trying to connect from server ‘ender’ to get a file on ‘bean’ follow this example:
- Connect to ender
- type:
ssh-keygen -t rsa- default directory for keyfiles will be ~/.ssh/
- if you do not want to be prompted, leave passphrase blank
- copy the contents of .ssh/id_rsa.pub (there should only be one line)
- place this line on bean, in ~/.ssh/authorized_keys
- that’s it, you should now be able to ssh/sftp/scp from ender to bean without being prompted for a password!
For further detail and a more complete example check this site out.
Update: You must have "RSAAuthentication yes" in your /etc/ssh/sshd_config file. On many Linux installations this setting is commented out in a default install
Tags: authentication, keygen, linux, pass phrase, password, scp, sftp, solaris, ssh, system administration, unix
Comments
14 Responses to “Password-less SSH Login”
Got something to say?

[...] Zach over at NoSheep has written a really nice article about how to configure a SSH trust relationship on UNIX systems. By doing this, you can prevent the system from prompting you for a password, thus allowing the user to use scripted solutions to move files around with sftp, etc. He didn’t mention, however, that to get this up and working correctly under Solaris, you have to uncomment the following lines in your /usr/local/etc/ssh_config file: [...]
Using these instructions I’ve just set up my Mac OSX desktop to connect to one of our servers without the need for a password.
I also saved the connection info in a terminal shortcut so I can connect to the server just as easily as I can open a terminal window.
Thanks for these instructions!
I was having trouble getting this working but a bit of research led me to making the authorized_keys file non group writeable… then it all burst into life
[...] Zach has posted a Zachgood quick reference for setting up SSH to use a shared key for authentication instead of a password on a UNIX system. It’s important to keep your keys secure, but this can allow you to set up scripts to execute commands or move files between multiple hosts without prompting for passwords. [...]
Maybe I’m paranoid, but having a private key without a passphrase freaks me out, so I use a key with a passphrase and then I use keychain (from the Gentoo project) to cache my decrypted keys in an ssh-agent process.
It’s too involved for me to post all the details, but if folks want, I could possibly detail it all in a blog post.
I’d certainly be curious.
One other thing that you may want to check is that the authorized_keys file is not group and world read/write permissions set. It got me stumped until I did a tail on the messages/secure log file to understand what was happening.
I have seen amny sites which give instructions for passwordless connection. But this one is really very handy and truly works fine.
For those who are as dense as myself.. authorized keys is a file, not a directory.. when you put it in, it is appending a file, not adding files to a directory.
[...] Zach has a good article about setting up ssh with key authentication which will allow you to use the scp and ssh commands without a password while still maintaining security. For more tips like this check out my book Easy Linux Commands, only $19.95 from Rampant TechPress. Buy it now! [...]
I am not sure about everybody else but for me the permissions on the .ssh directory were very important. I was not able to get this to work unless I removed all from group and other. A chmod 600 or 700 might be required.
Thanks for the help. Nice tutorial!
[...] a fairly low-tech solution, but its simple and it works for me. The only tricky bit was setting up passwordless ssh login so the script in part 2 could access the live server. It was a tad involved but I used the [...]
Hey guys can u help me.I’m unable to work with this.Can any one of u help me to find a solution for this..Please Please Please..
I have two servers named A & B.I need to connect to “B” and sens files from “A” using scp.it is asking me a password even though I done the above.Please help me to solve this..
[...] Furthermore, you can setup key authentication such that you can use scp without being prompted for a password (handy when working with wildcards). For details on doing that, see this tutorial on password-less ssh. [...]