I have created a Droplet and connect to it passwordless via SSH as root. While logged in as root, I created a new user ‘deploy’ which I want to use to deploy my app.

But, when I try to 'ssh deploy@ipaddr’ I get this error message: Permission denied (publickey).

I’m guessing it’s trying to authenticate with my root key instead of asking me for the deploy users password. How can I get around this little issue?

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.

Submit an Answer
2 answers

I guess that you have not properly configure SSH access for the deploy account. Assuming that you use the same computer (or the same private key) to connect to the deploy and root accounts on your server. You must add the corresponding public key to the ~/.ssh/authorized_keys file of your deploy account. After logging in to your root account, run the following command:

  • rsync --archive --chown=deploy:deploy ~/.ssh/authorized_keys /home/deploy/.ssh

Then, you can login the deploy account with ssh deploy@ipaddr

You may read this tutorial for more information:
Initial Server Setup with Ubuntu 20.04
. It contain links for other operating systems too.

by Brian Boucheron
When you first create a new Ubuntu 20.04 server, you should perform some important configuration steps as part of the basic setup. These steps will increase the security and usability of your server, and will give you a solid foundation for subsequent actions.

HI @nolyoi,

By default, the servers in DigitalOcean come with Password Authentication disabled. In this regard, when creating a new user, it would be best to create a home directory for it as well. In that home user directory, you can add your SSH key.

Another solution would be to enable password authentication and you would be able to ssh to the user with the password you’ve set it up for. Let me know which of the two you would prefer more and I’ll provide you with detailed steps.