CentOS 6 : SSH Server refused our key


Gossh.. It delayed my works for almost two weeks until I figure it out today. The SSH key making works fine in ubuntu, but on CentOS, it somehow doesn’t works.

So I read this thread, that lead me to this thread, and found a solution from this known issues in CentOS 6. Thanks God, they invented google.

Resume :

If “Server refused our key” error while login with private key happens even after you copied the public key into ~/.ssh/authorized_keys, then maybe it’s SELinux context issue.

when I tried to login using the private key, I got this:

Using username “root”.
Server refused our key
root@xxx.xxx.xxx.xxx‘s password:

Then login into that normally (using your root password), and try this before you attempt another login using private key :

/sbin/restorecon -r /root/.ssh

And just make it sure you’ve set ~/.ssh into 700 mode, and ~/.ssh/authorized_keys into 600 mode

chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys

They said :

Make sure that you setup correctly the selinux context of the public key if you transfer it to a CentOS 6 server with selinux enabled. Otherwise selinux might forbid access to the ~/.ssh/authorized_keys file and by matter of consequence key authentication will not work.

Hope it works with you.


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s