How to create a new SSH user in LAMP stack?

March 29, 2014 2.4k views
I created a fresh LAMP stack droplet. Now I have to provide my co-worker with access to server web directory (/var/www/) via SFTP. How could it be done right way?
1 Answer
You can simply add a new linux user for him and grant him access to write to /var/www.

  • Create a linux user for him: https://www.digitalocean.com/community/articles/how-to-add-and-delete-users-on-ubuntu-12-04-and-centos-6

  • Grant him access to write to /var/www. You can do that by adding a new group called e.g. "developers", adding both your users to it, setting all of the files in /var/www to be owned by the developers groups, and granting it write access:
    #create group:
    groupadd developers
    #add your users to it
    usermod -a -G developers username1
    usermod -a -G developers username2
    #chgrp /var/www to devvelopers
    chgrp -R developers /var/www
    #grant its users write access
    chown -R g+w /var/www

Hope that helps!
by Etel Sverdlov
This tutorial covers the basic commands to add, grant permissions to, and delete users. It is written for both CentOS and Ubuntu.
Have another answer? Share your knowledge.