Root permission control in Linux

Source: Internet
Author: User
Linux is a popular network server operating system. it inherits the security, stability, and efficiency of UNIX systems. In Linux, Root has the highest permissions, because such attackers often aim to obtain Root permissions. How can an administrator effectively manage the Root user? From the perspective of permission control LinuxIs a popular network server operating system. it inherits the security, stability, and efficiency of UNIX systems. In Linux, Root has the highest permissions, because such attackers often aim to obtain Root permissions. How can an administrator effectively manage the Root user? This article provides several security techniques from the perspective of permission control.

  Demo environment

Red Hat Enterprise Linux 5

  1. remote logon

We know that in the RHEL system, Root users are allowed to log on remotely by default. If the attacker obtains the Root password and then performs remote logon, the entire server will be compromised. Therefore, we need to set Root permissions to deny remote logon. In this way, even if attackers obtain the Root password, they cannot remotely log on to the server and control the server. There are many ways to restrict remote Root logon. I recommend two methods.

  (1) SSH restrictions

We know that SSH is a service used for remote maintenance management in Linux, similar to Telnet or remote desktop 3389 in Windows. Use SSH to restrict Root remote logon. All we need to do is modify the SSH configuration file. Find the/etc/ssh/sshd_config file and add PermitRootLogin no. Note that the Linux system is case sensitive and should not be entered incorrectly. After entering the information, save and exit, and then enter the command service sshd restart to restart the SSH service for the modification to take effect. In this way, when the Linux server is remotely connected through Root, the connection will be rejected. ()

  (2) PAM authentication

We can also use the PAM authentication module to deny Root users from directly logging on to the system. the following operations can be used to achieve this. Open/etc/pam. d/sshd file. add the auth required/lib/security/pam_listfile.so item = user sense = deny file =/etc/sshduser onerr = succeed statement to the first line. It indicates whether the account and password are valid during logon. you can log on to the system only after the authentication is passed. Otherwise, the logon is denied after the authentication is completed. Its Authentication Module is/lib/security/pam_listfile.so. the authenticated user is a user or a group. The authentication method is deny ), the authentication file is/etc/sshduser, and the file name and directory are random. if the authentication is successful, the system returns (succeed ). ()

Then, create an authentication file and run the echo "root">/etc/sshduser command on the terminal to create the file. of course, we can also use vi to open the sshduser file to add the file to the user. Note that when multiple users exist, each user occupies one row. After the addition is complete, use Root to log on to the server and you will be able to see that the logon is denied. ()

2. su restrictions

We know that there is a su command in Linux. by default, anyone can switch to the Root user to know the password of the Root user. For example, gslw, a common user in the users group, can switch to the Root user through the su command. ()

Therefore, we need to restrict SU to allow only users in a specific group to SU to the Root user. The method is implemented through the PAM authentication module. We previously controlled the ssh service by using the/etc/pam. d/sshd file. of course, to control the user to use the su command, we need

Modify the/etc/pam. d/su file. Open the file and modify it. Alternatively, enter the command vi/etc/pam. d/su in the terminal command window, and remove the # auth required pam_wheel.so use_uid annotation. ()

It indicates that the current user's UID is checked using the pam_wheel.so file. if it is not in the whell group, the user is rejected directly. Now we use the gslw user to log on to the system, and then su to the Root to see the rejection. Of course, to enable su to Root, you must add it to the wheel group. ()

 3. Root permission

As you know, Root has the highest permissions and often uses root users to manage the system, which brings security risks to the system. For example, a destructive command that is accidentally input may bring a devastating blow to the system. In addition, if the system is implanted with a sniffer tool, if you log on to the system as root, the root password will be stolen. Therefore, we need to reduce the Root permission so that other users can do some Root work and avoid excessive use of Root users.

How to delegate permissions to Root is determined based on the nature of the server. For example, a Linux apache server, commands frequently used by administrators are commands such as/usr/local/apache2/bin/apachect1 start/stop/restart to start, restart, and stop the server. We can create a gslw to manage the apache server. we know that normal users do not have the permission to start the apache server. The sudo command is used here. it adds extended permissions to gslw users so that they can manage apache servers.

Use Vi or directly enter/etc/pam. d open the sudo file and add a gslw ALL = (ALL)/usr/local/apache2/bin/apachectl command in it. The command is divided into four fields, namely the user name, the target object, the identity of the user to run and the command to run. Of course, you can also add gslw localhost = (root)/usr/local/apache2/bin/apachectl start to filter more strictly. After saving and exiting, log on to the system using the gslw user and run the/usr/local/apache2/bin/apachectl start command. The above is just an example. you can add corresponding command lines to the sudo file as needed. However, it should be noted that the command must be strictly filtered, and do not assign excessive permissions. ()

  Summary: The permission control in Linux is very strict, but it is also very flexible. we can deploy defense based on our own security requirements. Of course, there are still many control policies and methods for Root permissions. I hope the ideas provided in this article will be helpful to you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.