By Wheatey
So I followed one of the tutorials on here and generated SSH keys through Putty for the root user on my Ubuntu VPS. I can log into the VPS fine with the root user using the SSH keys. Now i want to add another user but how do I log in using an SSH key? Do i have to create another private key for the new user?
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!
If you would like to have the new use login with his own SSH key, you should create a new key and add it to the user. To do that, first of all create a new user with your root user:
adduser mynewusername
After this, you need to create a new Public/Private key. You can do this for example using PuttyGen on your own client or in your linux server. Once you got the keys, upload the public key to your droplet. Now we will put it in the right place. You should be adding this key to the user’s authorized_keys file, but we don’t have that file yet, so we’ll just move it and set permissions. With your new user in the home directory:
$ mkdir .ssh
$ mv id_rsa.pub .ssh/authorized_keys
$ chmod 700 .ssh
$ chmod 600 .ssh/authorized_keys
After this is done, you should be able to login to your droplet with your new user using the SSH private key.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.