Linux – ssh private key works for root, but not for normal user

linuxopensshputty

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 root@myhost.org   -- works, meaning the key is OK.
ssh -i mykey user2@myhost.org   -- 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. )

Edit:

The specific error with ssh:

The authenticity of host '[myhost.org]:22 ([1.7.1.2]:22)' can't be established

Plink: "Server refused our key"

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

Best Answer

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.

Related Question