Can't SSH into server as newly created user (Permission denied (publickey)

Viewed 25

I can access my server via ssh using root@{ip}

  1. I then create a new user adduser username
  2. I add the user to the sudo group usermod -aG sudo username
  3. I add my public key to the authorized_keys of the new user sudo cp /root/.ssh/authorized_keys /home/username/.ssh/authorized_keys
  4. I then try to ssh into the server as the new user ssh username@{ip}
  5. I get the error: Permission denied (publickey).

I know there are lots of similar questions but I can't figure out what I've done wrong. Please help!

I'm using a DigitalOcean Ubuntu droplet.

I've tried changing the owner of the authorised_keys file, changing permissions to 777, restarting the ssh service and some others.

2 Answers

Have you verified the sshd_config file that it allows ssh at all or with keys?

Related