sshd error shows double slash in authorized_keys path

129 Views Asked by At

My server has an ssh user that works (so sshd works).

When I added another user bob, then tried to connect, the client shows:

[email protected]: Permission denied (publickey).

And the server's logs show:

sshd: Could not open user 'bob' authorized keys '/home/bob//.ssh/authorized_keys': Permission denied

That double slash is probably the issue. Where is that coming from?

2

There are 2 best solutions below

0
Freeman On BEST ANSWER

As I understand it shows that there is an issue with the path to the authorized_keys file! usually it's related to the permissions of .ssh directory or the user's home directory.

the .ssh directory should have permissions of 700 and the authorized_keys file should have permissions of 600

so check them first :

ls -ld /home/bob/
ls -ld /home/bob/.ssh/
ls -l /home/bob/.ssh/authorized_keys

to fix that you can easily do like this :

chmod 700 /home/bob/.ssh
chmod 600 /home/bob/.ssh/authorized_keys

if the permissions are correct,restart ssh service and test it again

sudo systemctl restart sshd

also check the authorized_keys must be in this path :

/home/bob/.ssh/authorized_keys

good luck !

3
lonix On

$ cat /etc/passwd | grep bob:

bob:.......:/home/bob/:/bin/bash

So I did:

sudo usermod --home /home/bob bob

$ cat /etc/passwd | grep bob:

bob:.......:/home/bob:/bin/bash

NOTE:
Linux ignores double slashes in paths, so although this "fixed" the log error on the server, the underlying issue remained. To fix that, see the accepted answer.