0

I'm trying to setup SSH authentication via RSA files on Ubuntu 16.04 Server.
I generated key files on my local machine, then used

ssh-add  ./id_rsa

and copied id_rsa.pub to ~/.ssh/authorized_keys then changed permissions

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys.

It works fine for one user, I type ssh user@host on my local machine and it connects automatically without asking password. But when I do all the same steps for another user, ssh asks for a password and after three unsuccessful login attempts it writes

Permission denied (publickey,password).

closed as off-topic by Jeff Schaller, Rui F Ribeiro, G-Man, jimmij, mdpc Jan 15 '18 at 23:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, Rui F Ribeiro, G-Man, jimmij, mdpc
If this question can be reworded to fit the rules in the help center, please edit the question.

  • The keys must existing the .ssh directory of each users i.e. /home/<username>/.ssh – Raman Sailopal Jan 8 '18 at 13:53
  • They do. I have the same ~/.ssh/authorized_keys file with the same permissions in both users' home directories. – Sun Tzun Jan 8 '18 at 14:22
  • 1
    Did you change ownership of the file? What do you have in sshd logfiles? – Patrick Mevzek Jan 8 '18 at 14:36
1

The problem was in ownership of the file. I've changed owner of ~/.ssh directory to the user, which I tried to login as, and passwordless access began to work.

  • you should accept your own answer – Kiwy Jan 8 '18 at 16:01

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