Ubuntu SSH Server: Permission Denied (publickey)

Jul 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.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.