Question

Unable to SSH as new user

Hi there!

After creating a new user account and adding to sudo list, when I try to SSH as that user, I get a “permission denied (publickey)” notice. I am not sure what is going on.


Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Accepted Answer

I think I have managed to resolve this using the steps here.

This can happen for a few reasons. One is that you have not added the key as an authorized key for that user.

If you added a Public and Private key pair when you provisioned the droplet you can copy the /root/authorized_keys file to the users ~/.ssh directory with the commends below (as root)

cp /root/authorized_keys /home/USERNAME/.ssh
chown -R USERNAME:USERNAME /home/USERNAME/.ssh/*
chmod -R 0600 /home/USERNAME/.ssh/*

The above commands copy the authorized_keys file to your users home/.ssh directory and sets the user/group ownership and file permissions. REPLACE USERNAME WITH YOUR USERNAME

Another reason is your system has to many keys loaded and is failing due to multiple authorization failures. Try:

ssh -i ~/.ssh/private_key USERNAME@IP/HOST

Please keep in mind the key pair needs to match as an authorized pair for this user as noted above.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.