Restrict useradd in linux sudoers

Source: Internet
Author: User

In linux sudoers, sudo, which restricts useradd, is familiar to everyone. It allows an account to execute some applications as other identities. The problem we encountered today is that we want tom users to manage system accounts. However, if tom executes useradd with-g root or useradd-G root for the tom account, security issues may occur. So you need to limit it. Of course, it is good to limit the passwd command: tom ALL = (ALL)/usr/bin/passwd [A-Za-z] *,! /Usr/bin/passwd root this is because passwd is followed by a very small number of parameters. For the useradd command, there are many parameters. This won't work, for example, tom ALL = (ALL)/usr/bin/passwd [A-Za-z] *,! /Usr/bin/passwd root,/usr/sbin/useradd [a-zA-Z] *,! /Usr/sbin/useradd-G root [a-zA-Z] * If sudo useradd-u 1000-G root user1 is executed, the operation can still be successful. I thought about it. I have to match any combination of-G and other parameters. After some tests, write: tom ALL = (ALL)/usr/bin/passwd [A-Za-z] *,! /Usr/bin/passwd root,/usr/sbin/useradd [a-zA-Z-/] *,! /Usr/sbin/useradd [a-zA-Z-/] *-G root [a-zA-Z-/] *,! /Usr/sbin/useradd [a-zA-Z-/] *-g root [a-zA-Z-/] * This does not include numbers or-g root, can be added according to similar times.

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.