Skip to content

Instantly share code, notes, and snippets.

@exonomyapp
Created August 24, 2024 08:42
Show Gist options
  • Save exonomyapp/ac347a5889ef24f4cf71fb7fa2e48340 to your computer and use it in GitHub Desktop.
Save exonomyapp/ac347a5889ef24f4cf71fb7fa2e48340 to your computer and use it in GitHub Desktop.
How to set up a Shared Projects folder on our VPS

When setting up a shared projects folder for multi-user access to all the code we're developing on your VPS and where multiple users have their own accounts, we’ll want to choose a location that is accessible to all users but also secure. Here’s how we can achieve this on our Ubuntu 24.04 VPS:

Step 1: A location for the shared code folder to which users can be given access

A good place to store the shared code folder is within the /opt directory, which is typically used for optional software packages and can be a good place for shared resources.

For example, we can create the directory /opt/projects.

Step 2: Create the Shared Folder

First, create the directory where the code will be stored:

sudo mkdir /opt/projects

Step 3: Create a User Group

Next, create a group that all users who need access to the code folder will be added to. This allows for group-based access control.

sudo groupadd devs

Step 4: Change the Group Ownership of the Folder

Change the group ownership of the directory to the new devs group:

sudo chown :devs /opt/projects

Step 5: Set the Correct Permissions

Set the permissions on the directory so that the group members have read, write, and execute permissions:

sudo chmod 2775 /opt/projects
  • The 2 in 2775 ensures that any files or directories created within the /opt/projects directory inherit the group ownership.
  • The 775 ensures that the owner and group members can read, write, and execute files, while others can only read and execute.

Step 6: Add Users to the Group

For each user that needs access to the shared folder, add them to the devs group:

sudo usermod -aG devs username

Replace username with the actual username of each user who needs access.

Step 7: Verify the Setup

After setting up, verify the permissions by logging in as a different user and ensuring they can access and create files in /opt/projects.

Additional Considerations

  • Backup: Regularly back up the contents of /opt/projects to prevent data loss.
  • Monitoring: Consider using monitoring tools to track access to the shared folder if security or auditing is a concern.
  • Advanced Permissions: For more granular control, we could look into using ACLs (Access Control Lists) instead of basic Unix permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment