Home  >  Article  >  System Tutorial  >  Customize the mocking information of the sudo command when entering an incorrect password

Customize the mocking information of the sudo command when entering an incorrect password

王林
王林forward
2024-01-02 16:04:561172browse
Introduction sudoers is the default sudo security policy plug-in in Linux, but experienced system administrators can customize security policies and input and output logging plug-ins. It is driven by the file /etc/sudoers, or it can be in LDAP.

You can define sudoers mocking or other options in the file above. It is set under the defaults section.

自定义 sudo 在你输入错误的密码时嘲讽信息

In this article, we will explain a sudoers configuration parameter to allow individuals or system administrators to set up sudo commands that "taunt" system users when they enter incorrect passwords.

First open the file /etc/sudoers as shown below:

$ sudo visudo

Go into the defaults section and add the following lines:

Defaults   insults

The following is the defaults section that is displayed by default in /etc/sudoers in my system.

自定义 sudo 在你输入错误的密码时嘲讽信息

Set sudo insults parameters

From the screenshot above, you can see that there are many other default value definitions in defaults, such as sending an email to root every time the user enters a wrong password, setting a safe path, configuring Define sudo log files, etc.

Save and close the file.

Run the sudo command with the wrong password and observe how the insults option works:

$ sudo visudo

自定义 sudo 在你输入错误的密码时嘲讽信息

Practice sudo insult

Note: When configuring the insights parameter, it will disable the badpass_message parameter, which will output a specific message on the command line when the user enters an incorrect password (default The message is "sorry, try again").

To modify the message, add the badpass_message parameter to the /etc/sudoers file as shown below.

Defaults  badpass_message="Password is wrong, please try again"  #try to set a message of your own

自定义 sudo 在你输入错误的密码时嘲讽信息

Set sudo incorrect password message

Save and close the file, then call sudo To see how it works, the badpass_message message you set will be displayed every time you or any system user enters an incorrect password. print it out.

$ sudo visudo

自定义 sudo 在你输入错误的密码时嘲讽信息

sudo password error message

That's it, in this article we review how to set sudo to display a mock when the user enters the wrong password. Please share your thoughts via the comment box below.


About the Author:

自定义 sudo 在你输入错误的密码时嘲讽信息

Aaron Kili is a Linux and F.O.S.S enthusiast, future Linux SysAdmin, web developer, and currently a content creator at TecMint who loves working with computers and believes in sharing knowledge.


The above is the detailed content of Customize the mocking information of the sudo command when entering an incorrect password. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete