PuTTYgen SSH manual key installation for new users is not working

Today I have encountered an interesting issue. I am learning how to work with Ubuntu servers and this morning I have successfully set up a server with nginx for Django. However, I can’t figure out how did I manage to get the SSH authentication working.

I used PuTTYgen. I assigned my SSH public key to my droplet. But now when I try to create a new droplet, it ends up like that: I can log in to the server as root user, but whenever I try to add a new non-root user and assign the public key to it, then I am not able to log in as that user using SSH and I get the “Permission denied(Publickey)” response.

Here are the commands I use once I log in to the server for the first time as the root user:

adduser myuser
usermod -aG sudo myuser

su - myuser

mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys

Then I paste in the public key I got from the PuTTYgen and save it. And after that I do:

chmod 600 ~/.ssh/authorized_keys

Once this is done I check the /etc/ssh/sshd_config if the settings look like this:

PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no

And after that, when I switch back to the root user and I try to use the command,

ssh myuser@server_ip

it still doesn’t work…

Any ideas?


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

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.

I’m having the same issue… If you solved please tel me how…