Friday, October 25, 2013

Amazon ec2 ssh Server refused our key

Sponsored Links
I was getting Server refused our key error while trying to login in my Amazon ec2 instance. It was working perfect. When I checked the authorized keys, all the keys are there. Also sshd_config file is intact.


Then I checked the logs, and secure log gave the cause.
[root@xx.xx.xx.xx ~]# tail -f /var/log/secure
Oct 24 02:23:14 xx.xx.xx.xx sshd[2736]: Server listening on 0.0.0.0 port 22.
Oct 24 02:24:04 xx.xx.xx.xx sshd[3131]: Accepted publickey for root from xx.xx.xx.xx port 25919 ssh2
Oct 24 02:24:04 xx.xx.xx.xx sshd[3131]: pam_unix(sshd:session): session opened for user root by (uid=0)
Oct 24 02:24:08 xx.xx.xx.xx sshd[3131]: pam_unix(sshd:session): session closed for user root
Oct 24 02:26:32 xx.xx.xx.xx sshd[3162]: Authentication refused: bad ownership or modes for directory /root
Oct 24 02:26:32 xx.xx.xx.xx sshd[3163]: Received disconnect from xx.xx.xx.xx: 14: No supported authentication methods available
Oct 24 02:41:50 xx.xx.xx.xx sshd[3168]: Authentication refused: bad ownership or modes for directory /root

So I checked the ownership of the /root directory and found to be wrong. Because of this ssh were not able to read authorized key file properly.
[root@xx.xx.xx.xx ~]# ll -d /root/
drwxr-xr-x 4 nfsnobody nfsnobody 4096 May 11  2012 /root/
[root@xx.xx.xx.xx ~]# chown -R root. /root/
[root@xx.xx.xx.xx ~]# ll -d /root/
drwxr-xr-x 4 root root 4096 May 11  2012 /root/

Thats it.After that everything worked fine.
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.