Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried pretty much everything I could to make this work. I spent literally 6 hours on research and nothing helps to remove "Server refused our key" error. My username I tried to make is "Testuser" but I logged in SSH as root, should I also chown Testuser:Testuser authorized_keys?

I originally tried this and everything alike: http://www.howtoforge.com/ssh_key_based_logins_putty_p3 Then I followed this and still does not work : http://www.walkernews.net/2009/03/22/how-to-fix-server-refused-our-key-error-that-caused-by-putty-generated-rsa-public-key/

share|improve this question
So what precisely did you try? Copy paste any command that you typed and any file that you edited. My answer explains the most common difficulty; if it doesn't help, then tell us what you tried, don't just tell us that you tried something. – Gilles Nov 1 '11 at 20:19

If you want to log in as Testuser, then yes, you need to make sure that ~Testuser, ~Testuser/.ssh and ~Testuser/.ssh/authorized_keys belong to the user Testuser, and that all three are not writable by any other user, i.e.

chown Testuser ~Testuser ~Testuser/.ssh ~Testuser/.ssh/authorized_keys
chmod go-w ~Testuser ~Testuser/.ssh ~Testuser/.ssh/authorized_keys

Note that the prefered way to upload a new key to an account is to use ssh-copy-id. It would arrange for permissions to be correct.

You can also have ~Testuser/.ssh and ~Testuser.ssh/authorized_keys owned by root, but that's only for unusual setups where you don't want the user to be able to change the list of authorized keys. The file must be readable by Testuser in any case.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.