DigitalOcean: ssh Permission denied (publickey) when SSH as Created User

Allowing password login will undermine the safety of server, so instead we can set up SSH login for each user.

The important point is that:

  • for every user created on the server, each of their ~/.ssh/authorized_keys needs to be set up to include local machine’s public key.

To add authorized key to your server, SSH in as root user on server:

$ su your_user
$ mkdir -p ~/.ssh
$ nano ~/.ssh/authorized_keys

Copy the content of your local machine’s public SSH key and paste it into this file.

Reference: here or bottom of here.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.