I've set up an Ubuntu server with two users: 'admin' and 'user'. The 'admin' user can SSH into the server without any issues, but when 'user' tries to connect, they get refused. Running the command `ssh -vvv user@server` shows that it gets to the point of offering public keys but ends with a debug message indicating it can't access the `authorized_keys` file for the 'admin' user. I've checked that all permissions for the '.ssh' directory, 'authorized_keys', and key pairs are correct for both users. I even enabled debug logging in the SSH configuration and saw that during the user authentication process, it's trying to use the 'admin's `authorized_keys`. I tried modifying the `sshd_config` by uncommenting the `AuthorizedKeysFile` option and setting it to `%h/.ssh/authorized_keys`, but there hasn't been any change. What could be going wrong?
3 Answers
It sounds like your SSH configuration might be misconfigured. If the server is trying to open the 'admin's `authorized_keys`, that typically means the authentication setup isn't pointing to the correct user's file. Double-check that your user's home directory and `.ssh` folder are properly set up with the necessary permissions. You might also want to ensure the ownership of those files is correct—run `chown -R user:user /home/user/.ssh` to set it right.
Check the SSH daemon status with `systemctl status sshd` to confirm that it's the correct service running. Sometimes an alternate SSH service might be listening, which could cause confusion during the login attempts. Also, verify that your logs aren't indicating another user being passed through by mistake.
Absolutely! It’s crucial to ensure that the SSH daemon is properly configured. Checking the logs for any unexpected behavior can provide hints too.
Permissions can really trip you up in these situations. Make sure the `authorized_keys` for 'user' has the correct permissions set to `600` and the `.ssh` folder is `700`. If they're set to something else, it might block SSH from reading the keys properly.
Yeah, I had an issue like that. Permissions are key here. And don't forget that the home directory should also have the right permissions, usually `755`.

Good point! Also, make sure to check that your `.ssh/config` file isn’t causing any conflicts with your SSH setup.