Wheatey
By:
Wheatey

How do I log in with a new user to Ubuntu 14.04 with SSH keys through Putty after setting up keys for root?

August 23, 2015 1.4k views
Linux Commands DigitalOcean Ubuntu

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?

1 Answer

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.

Have another answer? Share your knowledge.