Super User is a question and answer site for computer enthusiasts and power users. 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 have a linux (ubuntu 12) server, and a windows desktop.

i am trying to connect via ssh and private key

the server has these files

rw------- root.root /root/.ssh
rw------- root.root /root/.ssh/authorized_keys

rw------- user2.user2 /home/user2/.ssh
rw------- user2.user2 /home/user2/.ssh/authorized_keys

(i.e. chmod 600 for both .ssh directory AND the auth-key file)

The contents of "authorized_keys" is a copy for both root and user2. Only ownership is different.

When trying to connect from the desktop:

ssh -i mykey   -- works, meaning the key is OK.
ssh -i mykey   -- doesn't work, for the same "mykey" file!

(Priv key fail, but password login works anyway, so it's not about server not accepting this user at all)

What could possibly be different between the root and user2?

(I tried also plink, putty's version for "ssh'ing", with PPK file - same results, so it's not a bug in ssh :) i think. )


The specific error with ssh:

The authenticity of host '[]:22 ([]:22)' can't be established

Plink: "Server refused our key"

(ip/port/host in this msg are fake)

share|improve this question
As per… the .ssh directory needs to have 700 permissions. – Martin Prikryl Apr 26 '13 at 15:40
Thank you, that was correct. it solved my problem, but I still wonder then why there's a difference between root and "user2", and how comes I never encountered the need for 700 in the past decade! – Berry Tsakala Apr 26 '13 at 16:05
I suppose that root has all permissions implicitly. – Martin Prikryl Apr 26 '13 at 16:45
@MartinPrikryl: could please make your comment an answer, so that the question doesn't remain unanswered? – Cristian Ciupitu Oct 22 '13 at 19:22
@CristianCiupitu Ok, Done. – Martin Prikryl Oct 23 '13 at 7:39
up vote 4 down vote accepted

As per question ~/.ssh/authorized_keys not working properly the .ssh directory needs to have 700 permissions.

The reason, it works for root even without the permissions set properly, is that root has implicit permissions for everything.

share|improve this answer
It's always weird when you're connect as a non-root user and you see that there's files you can't write into ^^ – mveroone Oct 23 '13 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .