SSH public key authentication does not work

Created:

2016-11-16 12:55:20 UTC

Modified:

2017-06-23 11:25:10 UTC

0

Was this article helpful?


Have more questions?

Submit a request

SSH public key authentication does not work

Applicable to:

  • Plesk

Symptoms

Providing a system user with an ability to log in to a server using SSH public key does not work.

Cause

The home directory of each SSH user in Plesk is write-protected.

OR

Permissions of the file authorized_keys are incorrect.

Resolution

Since Plesk 12.0.18 and above such functionality can be managed with SSH Keys Manager extension. Go to Home > Extensions > Extenstions Catalog and install SSH Keys Manage.

Note: Make sure that the file authorized_keys has correct permissions. It should be accessible only by the owner:

# ls -l ~/.ssh/authorized_keys
-rw------- 1 root root 399 Jul 15  2016 /root/.ssh/authorized_keys

Alternatively, use the following workaround:

  1. Edit /etc/ssh/sshd_config. Add this line or change an existing one to the following:

    AuthorizedKeysFile .ssh/authorized_keys %h/private/.ssh/authorized_keys

    This will make SSH search for .ssh directory in the private directory of each user not only for the root home directory.

  2. Save the file and restart the sshd:

    # service sshd restart

To use SSH public key customer has to add an authorized_keys file. It should be done as follows:

  1. Log into customer account under provided SSH user and run these commands:

    # cd private
    # mkdir .ssh
    # chmod og-xrw .ssh
  2. Copy authorized_keys file to the created .ssh directory.

Have more questions? Submit a request
Please sign in to leave a comment.