How to Configure User Access Restrictions on Your Server

calendar_month September 28, 2024 schedule 1 min read visibility 3 views
person
Valebyte Team

Step 1: Creating User Groups


First, you need to create user groups to which different levels of access on the server will be assigned. To do this, use the command
sudo groupadd [group name]
. Create the required number of groups depending on the requirements of your project.

Step 2: Adding Users to Groups


After creating user groups, you need to add the users themselves to these groups. To do this, use the command
sudo usermod -aG [group name] [username]
. Repeat this step for all users for whom you need to set access restrictions.

Step 3: Configuring File and Directory Permissions


To set access restrictions on specific files and directories, you need to use the command
chmod
. For example, to restrict access to a file, use the command
sudo chmod [permissions] [path to file]
.

Step 4: Configuring SSH Access


To manage access to the server via SSH, you need to edit the SSH configuration file. Open the file
/etc/ssh/sshd_config
and configure the access parameters for each user group using the directive
AllowGroups
.

Step 5: Restarting the SSH Service


After making all the necessary changes, restart the SSH service for them to take effect. To do this, use the command
sudo systemctl restart sshd
.

Conclusion


After completing all these steps, access restrictions for users on the server should be successfully configured. Make sure that all changes are applied correctly and that users only have access to the necessary resources.

Share this post: