Search code examples
sshsshd

sshd error shows double slash in authorized_keys path


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?


Solution

  • 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 !