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,
it still doesn’t work…