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:

  1. Connect to ender
  2. type: ssh-keygen -t rsa
    • default directory for keyfiles will be ~/.ssh/
    • if you do not want to be prompted, leave passphrase blank
  3. copy the contents of .ssh/id_rsa.pub (there should only be one line)
  4. place this line on bean, in ~/.ssh/authorized_keys
  5. 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

authentication, keygen, linux, pass phrase, password, scp, sftp, solaris, ssh, system administration, unix

Tags: , , , , , , , , , ,

Related:


Comments

14 Responses to “Password-less SSH Login”

  1. spiralbound.net » Changes to Solaris ssh_config for Password-less SSH Login on May 8th, 2006 4:44 pm

    [...] 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: [...]

  2. Jon on May 18th, 2006 8:39 am

    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!

  3. earle goodfellow on June 7th, 2006 12:37 am

    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

  4. Life After Coffee » SSH Without A Password on June 15th, 2006 6:30 pm

    [...] 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. [...]

  5. Marc on June 17th, 2006 12:48 am

    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.

  6. zbtirrell on June 18th, 2006 9:09 am

    I’d certainly be curious.

  7. kc on November 16th, 2006 9:03 pm

    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.

  8. Saurabh on November 22nd, 2006 3:31 am

    I have seen amny sites which give instructions for passwordless connection. But this one is really very handy and truly works fine.

  9. Storm on January 10th, 2007 1:00 pm

    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.

  10. Life After Coffee » Secure remote file copy on January 11th, 2007 6:43 pm

    [...] 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! [...]

  11. Dustin on March 23rd, 2007 8:39 pm

    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!

  12. Bash backup scripts including mysql backup at max words on April 12th, 2007 5:02 pm

    [...] 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 [...]

  13. sirish on July 31st, 2007 6:09 am

    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..

  14. Web App: File and/or Directory Backup, Part 1 | intarwebz online on August 29th, 2007 9:52 pm

    [...] 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. [...]

Got something to say?





User contributed tags: passwordless login (1296) - ssh trust (996) - t (865) - scp password (676) - ssh no password (616) - sftp password (451) - ssh password (180) - ssh passwordless login (171) - sftp script (171) - passwordless ssh solaris (169) - sftp passwordless (158) - ssh trust relationship (119) - ssh no login (119) - ssh without login (90) - sftp without password (89) - passwordless ssh login (83) - SSH password script (82) - sftp scripts (82) - ssh login script (80) - "scp without password" (79) - all (75) - ssh password solaris (75) - passwordless logins (66) - solaris ssh password (60) - unix ssh password (60) - passwordless scp (54) - ssh login password (50) - password less login (49) - ssh without password (48) - sftp login script (46) - f (44) - ssh nologin (44) - password less sftp (44) - passing password to ssh (43) - passwordless sftp (42) - solaris ssh passwordless (41) - scp with password (41) - ssh scripting (41) - ssh login without password (39) - ssh passwordless (39) - ssh passwordless connection (39) - pass password to ssh (39) - ssh passwordless solaris (38) - ssh password less login (37) - ssh scripts (37) - ssh script password (37) - porn tube password (37) - passwordless ssh (36) - ssh pass password (36) - sftp password script (35) - man scp password (35) - passwordless ssh "Solaris 10" (35) - ssh solaris password (34) - ssh_config password (34) - password less SSH (34) - ssh without password + unix (34) - scp passwordless (32) - ssh trusts (32) - man ssh password (32) - setting up passwordless ssh (31) - ssh with no password (31) - trust ssh (31) - script ssh login (31) - scp password script (31) - sftp login without password (31) - solaris passwordless ssh (30) - scp without password solaris (30) - ssh without pass (30) - "sftp Solaris" (30) - ssh script (30) - sftp password less (29) - unix ssh without password (29) - scp no password (29) - sftp unix script (29) - solaris ssh without password (29) - linux scp password (28) - "Solaris 10" ssh "no password" (28) - unix ssh "no password" (28) - passing password to sftp (28) - ssh password from file (27) - sftp with password (27) - pass password to scp (27) - ssh password less (26) - scp unix password (26) - SFTP login (26) - password less ssh login (26) - setup ssh trust (26) - sftp + NO PASSWORD (26) - sftp script password (26) - ssh password login (26) - password less scp (25) - SSH trust setup (25) - scp without login (24) - linux ssh passwordless (24) - sftp unix password (24) - Solaris 10 ssh authorized_keys (23) - no password porn (23) - sftp password UNIX (23) - sftp pass password (23) - linux sftp script (22) - ssh passwordless login solaris (22) - ssh no password solaris (22) - solaris + scp without password (22) - ssh trust key (22) - passing password to scp (22) - ssh trust relation (21) - setting up ssh trust (21) - Unix SCP, password (21) - sftp script example (21) - "solaris 10" passwordless ssh (21) - scp script password (20) - linux ssh trust (20) - ssh passing password (20) - sftp script linux (20) - UNIX scp script (20) - ssh login with password (19) - scp pass password (19) - sftp passwordless login (19) - sftp script examples (19) - ssh no passwords (19) - ssh keys no login (19) - Unix SCP, without password (19) - sftp passing password (19) - unix sftp password (18) - password sftp (18) - unix ssh script (18) - linux ssh login without password (18) - sftp without login (18) - solaris ssh no password (17) - passwordless ssh in solaris (17) - passwordless ssh UNIX (17) - script ssh password (17) - scp + passwordless login (17) - set up passwordless ssh (16) - linux passwordless ssh (16) - sftp script login (16) - scp password solaris (16) - Pass on Passwords with scp (16) - mss (16) - solaris ssh login without password (16) - ssh script login (16) - sftp password less login (15) - scp nologin (15) - ssh script no password (15) - solaris ssh login (15) - scp man password (15) - sftp without prompting for password (15) - ssh without password solaris (14) - scripting ssh login (14) - ssh no password login (14) -