I want to add an additional user with SSH key access

September 5, 2015 864 views
Linux Commands Security DigitalOcean Linux Basics

I already have a droplet setup with SSH key for root. Now I want to add an additional user with limited capability (Someone who can just deploy application on tomcat etc), with the same SSH key. How should I do it?

1 Answer

You could login as the root user on the droplet. After this create a new user (on CentOS: useradd username). After you've created the user, login as this user (can be done directly from root: su username).

Now edit the file: ~/.ssh/authorized_keys and paste the public key in this file. Save it and make sure you chmod it to 600. Now you could login as the newly created user with the SSH key.

If you're unable to login, please check the /var/log/secure login (as the root user) to see why you can't login. If it says something about not in the AllowUsers, then: nano /etc/ssh/sshd_config and at the end of the file, you could add the user: AllowUser username. Make sure to restart ssh.

Have another answer? Share your knowledge.