Ubuntu SSH Server: Permission Denied (publickey)

July 19, 2019

Check /etc/ssh/sshd_config file.

sudo nano /etc/ssh/sshd_config
  • Make sure AllowUsers USERNAME is available for your username.
  • If you login as root, make sure PermitRootLogin yes.
  • If you login with password, makr sure PasswordAuthentication yes.
  • If you just edited /etc/ssh/sshd_config, run sudo systemctl reload sshd for the changes to take effect.

Make sure the user have public key configured

  • Make sure ~/.ssh/authorized_keys exist.
  • If the file doesn’t exist, refer Copy Ssh Public Key.
  • If root have the public key, switch to root user and run sudo rsync --archive --chown=USERNAME:USERNAME ~/.ssh /home/USERNAME to copy root public key to USERNAME.
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.