Setting up a new user using SSH

I followed the tutorial for setting up myself with SSH login which worked fine. I have another user I need to add as well but I am not sure how to go about doing that. I have his public key and added it to the droplet on creation. Droplet is running ubuntu 18.04. Any help would be greatly appreciated. I’ve looked through several other tutorials and documentation for this as well but I just can’t seem to find exactly what I am looking for. I don’t think I can set him up the same way I set it up for myself.

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.

Site Moderator
Site Moderator badge
July 9, 2020
Accepted Answer

Hi @rconover,

You’ll need to create a new user and add the SSH keys there. I normally set and create their home directory at the same time.


Create Home Directory + .ssh Directory

mkdir -p /home/mynewuser/.ssh

Create Authorized Keys File

touch /home/mynewuser/.ssh/authorized_keys

Create User + Set Home Directory

useradd -d /home/mynewuser mynewuser

Add User to sudo Group

usermod -aG sudo mynewuser

Set Permissions

chown -R mynewuser:mynewuser /home/mynewuser/
chown root:root /home/mynewuser
chmod 700 /home/mynewuser/.ssh
chmod 644 /home/mynewuser/.ssh/authorized_keys

Set Password on User

If you want to be able to log in as the user without an SSH key, setting a password will allow that, as long as PasswordAuthentication is enabled in /etc/ssh/sshd_config.

passwd mynewuser

You can check the users home directory by running:

echo $HOME

… while logged in as the user. If you echo $PWD, it’ll give you the current path to the directory that you’re currently in. So if I ran cd /home, running:

echo $PWD

… will give me /home. If my home directory is /home/mynewuser, then $HOME will give me that directory :-).

Regards, KFSys

Hi there,

I followed the steps listed above by KFSys and it looks like everything worked properly but when I tried to use the user&pass inside the Jetpack backup settings, it’s saying that the connection fails. Any thoughts?

Besides that, I’m using Transmit (file transfer tool) and after the steps above I cannot connect to the server with the root user anymore :PANIC:

Site Moderator
Site Moderator badge
July 9, 2020

Hi, @rconover

You can check out our existing tutorial on how to add users on Ubuntu 18.04 here:

Additionally you can check that the user’s ssh key is present in the ~/.ssh/authorized_keys file and if not to add it there.

If the user needs a sudo access you can grant him access by following the tutorial.

Hope that helps!

Regards, Alex

Try DigitalOcean for free

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

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

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

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel