0

I have 2 users on a system, user1 and user2.

Here is the md5sum of authorized_keys for each:

de092f77fb4a3be2cd8864c5f9961149  user1/.ssh/authorized_keys
de092f77fb4a3be2cd8864c5f9961149  user2/.ssh/authorized_keys

Here is a list of the .ssh folder for each:

user1/.ssh/:
total 8
drwx------. 2 user1 user1   28 Mar 16 12:11 .
drwxrwx---. 5 user1 user1 4096 Mar 16 12:11 ..
-rw-------. 1 user1 user1  412 Mar 16 12:11 authorized_keys

user2/.ssh/:
total 4
drwx------. 2 user2 user2  28 Mar 16 11:37 .
drwx------. 3 user2 user2  90 Mar 16 11:38 ..
-rw-------. 1 user2 user2 412 Mar 16 11:37 authorized_keys

Here is authentication with each:

user1:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password

user2:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279

/etc/passwd:

user1:x:1001:1001::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash

In other words, I can log in with public key using user2, but not user1. Logging in with password works fine for both. I have no clue why this works with one user and not the other. And I need to get public key authentication to work with user1 (because I need to run scripts with an sshagent using public key authentication)

I am lost where to look for why this is not working. All guides online ask to check the key, the permissions, and regenerate. But all of the above looks correct. I find no mention of user1 in the /etc/ssh folder.

And if I provide the password, the login works fine.

Please note, I have edited the user names to anonymize the relevant data.

closed as off-topic by Jakuje, Anthony Geoghegan, dhag, Jeff Schaller, thrig Mar 16 '17 at 15:35

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." – Jakuje, Anthony Geoghegan, dhag, Jeff Schaller, thrig
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    check what the logs say on the server side – ilkkachu Mar 16 '17 at 11:30
2

The issue was the permission on the home folder, it allowed group to write.

  • In my case, it was authorized_keys permission. it should be 600 – Aftab Naveed Oct 6 '17 at 12:59
  • neither the home folder nor the authorized_keys permissions worked for me. Any other clue what might be happening? I'm getting the same debug messages as OP, the only difference being that the user that works is the root, others are not. PermitRootLogin is set to yes. – dvdblk 2 days ago

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