I just spent 20 minutes trying to figure out why my passwordless SSH wasn’t working. I’ve done it dozens of times, but this time it wasn’t working and none of the Google results had a solution that helped.
It turns out I was pointing to the public key instead of the private key.
Short summary: Don’t point to the .pub keyfile with IdentityFile in .ssh/config.
A lot of the solutions I found were related to invalid keyfiles, but I’d generated the key with ssh-keygen on that machine, so I was fairly confident the keys were valid.
If you’re having the same problem, use
ssh -vvv
to get more debugging info.
If this saves someone else 20 minutes, my wasted time will not have been in vain.
Thanks man. I was beating my head on this as well; also had IdentityFile pointing at the .pub.
» Comment by Brian Dunn on February 17, 2011 @ 9:08 amI’m glad this helped.
» Comment by Dan on February 17, 2011 @ 9:18 amI am running Centos 5.5. Had the issue above. As long as I specified a passphrase with ssh-keygen, publickey never worked. If I use a blank passphrase, it works first time, every time.
» Comment by Bill Cunningham on April 4, 2011 @ 11:06 am@Bill Cunningham Thanks for the additional data point.
» Comment by Dan on April 4, 2011 @ 11:56 amFound this after running ssh with the ‘-v’ option, and scroogling for ‘PEM_read_PrivateKey failed.’ Appreciate the information, I can’t believe I made such a rookie mistake!
Thanks for the help.
» Comment by Mike Davis on April 7, 2011 @ 3:32 am@Mike I felt the same way
» Comment by Dan on April 7, 2011 @ 9:11 amMy problem was completely different, but the ‘ssh -vvv’ tip helped me find it. I was using ‘ssh -v’ and that wasn’t enough verbosity to reveal the problem, but I saw it when running ‘ssh -vvv’. Thanks for the tip!
» Comment by Anon on April 12, 2011 @ 11:04 am@Anon No problem.
» Comment by Dan on April 12, 2011 @ 12:19 pmThank You!
» Comment by Javix on July 13, 2011 @ 3:20 pm@Javix No problem.
» Comment by Dan on July 13, 2011 @ 3:22 pmChalk up another “Thank you.” D’oh!
» Comment by Todd on August 30, 2011 @ 12:02 pmI’ll toss another “Thank you” in basket. Cheers!
» Comment by Ed on October 3, 2011 @ 12:34 pmThank you!
*Why can’t I remember this?*
» Comment by William Notowidagdo on November 24, 2011 @ 11:51 pm