Saturday, April 3, 2010

Debugging Password-less SSH Authentication

Whenever I need to frequently log into a Amazon EC2 server running Linux, the first thing I usually do is configure password-less login more properly known as public key authentication over SSH.

The steps described here are clear and to the point to help you get started.

The problem I had this time round was due to the folder/file permissions defined for the Linux user (apps) under which I was trying to login with. After some googling, I discovered that you could track SSH authentication attempts by 'tailing' this file: [tail -f] /var/log/secure which on some systems is: [tail -f] /var/log/security and then I noticed the error message --
Apr 3 17:12:36 domU-XX-XX-XX-XX-XX-XX sshd[2626]: Authentication refused: bad ownership or modes for directory /home/apps/.ssh

Rather than 'waste' time solving the permissions problem (after a few attempts I didn't make much progress) I settled with passwordless login as root! I know it's not exactly a good practise but hey the instance is not exactly running mission-critical apps anyway nor does it contain sensitive financial information ....

2 comments:

  1. THANK YOU! I have been banging my head against the wall trying to figure out why one machine was working and the others weren't. The /var/log/secure file told me which directory had a bad permission and my problem cleared up immediately.

    Patrick in Ft.Worth, Texas

    ReplyDelete
  2. Glad my instructions were of help to you Patrick.

    ReplyDelete