Skip to content

Instantly share code, notes, and snippets.

@nathanieltubb
Last active November 7, 2016 22:27
Show Gist options
  • Save nathanieltubb/7f1f74497b93f678123a4ac0300408a7 to your computer and use it in GitHub Desktop.
Save nathanieltubb/7f1f74497b93f678123a4ac0300408a7 to your computer and use it in GitHub Desktop.
Adding New SFTP User on a Digitial Ocean Ubuntu Server

Adding A New SFTP User

As root or via sudo add the user with a home directory, where "developer" is the new username:

useradd -d /home/developer -m developer

Update the new user's password; making sure you use a very strong one:

passwd developer

If this user should have the ability to use sudo commands add them to the sudo group:

usermod -aG sudo developer

Add a .ssh directory for the user, and make sure it is owned by the new user:

mkdir -p /home/developer/.ssh

chown -R developer:developer /home/developer/.ssh

If you already have SSH keys setup for your root user that you wish to use for the new user, copy the authorized_keys file to the new user's .ssh directory though this is probably not recommended:

cp /root/.ssh/authorized_keys /home/developer/.ssh/authorized_keys

chown -R developer:developer /home/developer/.ssh

Now to make it easier to get to the web root we will add a sym-link to /var/www/html in the new user's home directory:

ln -s /var/www/html /home/developer/html

The new user won't have permission to make changes in the web root so let's change that by adding them to the www-data group:

usermod -aG www-data developer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment