Portal Home > Knowledgebase > Articles Database > SSH keys Permission denied (publickey)


SSH keys Permission denied (publickey)




Posted by waya, 10-28-2013, 07:01 PM
So the last time I tried to set up SSH keys I followed the tutorial here: https://help.ubuntu.com/community/SSH/OpenSSH/Keys and had it working within minutes. My client computer is on ubuntu and the host is centos 6. It's been about a year since and now I have to do it again and I'm having an issue. After restarting ssh and trying to login it still requests me for a password, so I turned PasswordAuthentication to no, but then I get a permission denied error for the public key. I've googled this and almost all sources state the issue is that the permissions are not set correctly on your .ssh folder and authorized_keys file. On the server my .ssh folder is 700 and the authorized_keys file is 600, but I'm still receiving this error. In my sshd_config file I have PubkeyAuthentication yes and RSAAuthentication yes. The signature in my authorized_keys matches my id_rsa.pub file. When I look in /var/log/secure it just says the connection was closed by my IP. The only thing difference from setting up since last time is that the user I'm trying to login as with the SSH key is root. Even though that probably may be frowned upon, it should still work shouldn't it? I've also tried deleting my entire ssh folder and starting again, but no luck. Anyone know what else I can try? Thanks.

Posted by serve-you, 10-28-2013, 07:37 PM
Try using debug on your ssh session to get more details.

Posted by steven99, 10-28-2013, 07:44 PM
Do you have anything in /etc/hosts.deny, like deny : all ? If so, in /etc/hosts.allow, put sshd : YOUR_IP : allow .

Posted by Scott.Mc, 10-28-2013, 07:50 PM
If this is EL6 you might need to set selinux to allow the .ssh folder with, restorecon -Rv /homefolder Such as restorecon -Rv /root

Posted by waya, 10-28-2013, 10:05 PM
Looks like this was my problem. It works now. I was searching for hours and didn't see anyone mention to do that. Thank you so much Scott!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Image uploader (Views: 577)
phpLibClamAV (Views: 589)