How to create a new SSH user in LAMP stack?

Posted March 29, 2014 5.8k 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?

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.

Submit an Answer
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:

  • 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.