Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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: Then I followed this and still does not work :

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

1 Answer 1

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.