Question

SSH Permission denied (publickey)

I have configured my droplet using the following guide -https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04

I then followed this guide to add a GUI - https://www.digitalocean.com/community/questions/how-to-install-graphical-interface

All the steps worked, until the step to establish a secure connection (Step 3 — Connecting to the VNC Desktop Securely).

I ran the code that was provided (changing the user parameter accordingly) -

> ssh -L 59000:localhost:5901 -C -N -l sammy your_server_ip

But I got the following error - Permission denied (publickey).

I do have SSH keys as the authentication method on root, and my non root user can login successfully. So I assume the key was copied successfully to that user.

I was required to set a password for the non root user, and I am not sure if that could be the cause of the error.

How can I fix this error and establish the SSH tunnel?


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
October 5, 2022

Hello @guyseynaeve

I will recommend you check this article

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-22-04

The initial setup does come as part of the requisites since in the VNC setup you’ll need a username. Make sure to setup ssh-keys for the username and re-try to connect.

Regards

KFSys
Site Moderator
Site Moderator badge
October 5, 2022

Hi @guyseynaeve,

When you go to your user’s home directory, in there do you see the .ssh/authorized_keys file? I’m not talking about /root/.ssh/authorized_keys but for your user sammy?

Additionally, make sure your permissions and ownerships are correct on the folder as well and that they are not root:root.

typically you want the permissions to be:

  • .ssh directory: 700 (drwx------)
  • public key (.pub file): 644 (-rw-r–r–)
  • private key (id_rsa): 600 (-rw-------)
  • lastly your home directory should not be writeable by the group or others (at most 755 (drwxr-xr-x)).

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.