Network Troublshooting > Linux Servers Support

Regular user Can't SSH using public Key but root can

(1/1)

Saahib:
Hi,

This is driving me nuts from few days. I have server where I can login as root user through SSH using public key authentication. I then added new user with SSH.

Added new user :

--- Code: ---adduser  -m newUser
--- End code ---

Created password for it :

--- Code: ---passwd newUser
--- End code ---

Added .ssh/authorized_keys with client machines public key (which is I am already using to log into as root from this client)

--- Code: ---echo "key here from client" >> /home/newUser/.ssh/authorized_keys
--- End code ---

I have double checked, triple checked.  Same key works for root login but not for new user.

I tried ssh to ssh with -v ,then last few lines:


--- Code: ---debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password
newUser@server.com's password:

--- End code ---

It looks like its my ssh server is not able read publickey ? I can login using password though.

I have done this in past many times, for root and normal user but this time its not working, driving me nuts...

I am sure I am making some tiny mistake.. but where it is ?

dalek:
I would check permissions of the key files and also check to be sure the user is a member of the correct groups.  I haven't used ssh in ages but seem to recall it requiring being a member of a certain group.  Given your output, it seems to be trying so that leads me to believe it is a permission issue with the key files.  I'd suggest setting it to be readable by all but only writable by root.  It may be that it can see the file exists but is unable to read the contents of the file. 

Hope that helps.

Saahib:
Oh man, it was driving from many days, it was indeed permission problem . I had checked actually , permission were 644 and ownership was also correct (owned by the user) however.

Looking around I found that we need following permission, I am sharing here for future reference:

--- Code: ---chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
--- End code ---

Problem was that I was comparing permission with root .ssh and its content but that doesn't work for regular user.

Navigation

[0] Message Index

Go to full version