mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-25 00:50:15 +08:00
translated
This commit is contained in:
parent
1865fccfbb
commit
9bc7aed6f7
@ -1,98 +0,0 @@
|
|||||||
translating---geekpi
|
|
||||||
|
|
||||||
Let Sudo Insult You When You Enter Incorrect Password
|
|
||||||
============================================================
|
|
||||||
|
|
||||||
Sudoers is the default sudo security policy plugin in Linux, however, experienced system administrators can specify a custom security policy as well as input and output logging plugins. It is driven by the `/etc/sudoers`file or alternatively in LDAP.
|
|
||||||
|
|
||||||
You can define sudoers insults option or several others in the file above. It is set under defaults entries section. Read through our last article that explains [10 Useful Sudoers Configurations for Setting ‘sudo’ in Linux][1].
|
|
||||||
|
|
||||||
In this article, we will explain a sudoers configuration parameter to enable an individual or system administrator set [sudo command][2] to insult system users who enter wrong password.
|
|
||||||
|
|
||||||
Start by opening the file `/etc/sudoers` like so:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo visudo
|
|
||||||
```
|
|
||||||
|
|
||||||
Go to the defaults section and add the following line:
|
|
||||||
|
|
||||||
```
|
|
||||||
Defaults insults
|
|
||||||
```
|
|
||||||
|
|
||||||
Below is a sample of /etc/sudoers file on my system showing defaults entries.
|
|
||||||
|
|
||||||
[
|
|
||||||

|
|
||||||
][3]
|
|
||||||
|
|
||||||
Set sudo Insults Parameter
|
|
||||||
|
|
||||||
From the screenshot above, you can see that there are many other defaults defined such as send mail to root when each time a user enters a bad password, set a secure path, configure a custom sudo log file and more.
|
|
||||||
|
|
||||||
Save the file and close it.
|
|
||||||
|
|
||||||
Run a command with sudo and enter the wrong password, then observe how insults option works:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo visudo
|
|
||||||
```
|
|
||||||
[
|
|
||||||

|
|
||||||
][4]
|
|
||||||
|
|
||||||
sudo Insult in Action
|
|
||||||
|
|
||||||
Note: When you configure the insults parameter, it disables the `badpass_message` parameter which prints a specific message on the command line (the default message is “sorry, try again”) in case a user enters a wrong password.
|
|
||||||
|
|
||||||
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
|
|
||||||
```
|
|
||||||
[
|
|
||||||

|
|
||||||
][5]
|
|
||||||
|
|
||||||
Set sudo badpassword Message
|
|
||||||
|
|
||||||
Save the file and close it, then invoke sudo and see how it works, the message you set as the value of badpass_message will be printed every time you or any system user types a wrong password.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo visudo
|
|
||||||
```
|
|
||||||
[
|
|
||||||

|
|
||||||
][6]
|
|
||||||
|
|
||||||
Sudo badpassword Message
|
|
||||||
|
|
||||||
That’s all, in this article we reviewed how to set sudo to print insults when users type a wrong password. Do share your thoughts via the comment section below.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
作者简介:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
via: http://www.tecmint.com/sudo-insult-when-enter-wrong-password/
|
|
||||||
|
|
||||||
作者:[Aaron Kili][a]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:http://www.tecmint.com/author/aaronkili/
|
|
||||||
[1]:http://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/
|
|
||||||
[2]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
|
||||||
[3]:http://www.tecmint.com/wp-content/uploads/2017/01/Set-sudo-Insults-Parameter.png
|
|
||||||
[4]:http://www.tecmint.com/wp-content/uploads/2017/01/How-sudo-Insult-Works.png
|
|
||||||
[5]:http://www.tecmint.com/wp-content/uploads/2017/01/Set-sudo-badpassword-Message.png
|
|
||||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/01/sudo-badpassword-Message.png
|
|
@ -0,0 +1,96 @@
|
|||||||
|
让 sudo 在你输入错误的密码时冒犯你
|
||||||
|
============================================================
|
||||||
|
|
||||||
|
sudoers 是 Linux 中的默认 sudo 安全策略插件,但是经验丰富的系统管理员可以自定义安全策略以及输入输出日志记录的插件。它由 `/etc/sudoers` 这个文件驱动,或者也可在 LDAP 中。
|
||||||
|
|
||||||
|
你可以在上面的文件中定义 sudoers insults 或其他选项。它在 defaults 部分下设置。请阅读通过我们的上一篇文章[在Linux中设置 `sudo` 时 10 个有用的 sudoers 配置][1]。
|
||||||
|
|
||||||
|
在本文中,我们将解释一个 sudoers 配置参数,以允许个人或系统管理员设置[sudo 命令][2]来冒犯输入错误密码的系统用户。
|
||||||
|
|
||||||
|
首先打开文件 `/etc/sudoers`,如下所示:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo visudo
|
||||||
|
```
|
||||||
|
|
||||||
|
进入 defaults 部分,并添加下面的行:
|
||||||
|
|
||||||
|
```
|
||||||
|
Defaults insults
|
||||||
|
```
|
||||||
|
|
||||||
|
下面是我系统中 /etc/sudoers 默认展示的 defaults 部分。
|
||||||
|
|
||||||
|
[
|
||||||
|

|
||||||
|
][3]
|
||||||
|
|
||||||
|
设置 sudo insults 参数
|
||||||
|
|
||||||
|
从上面的截图中,你可以看到还有许多其他默认值定义,例如,当每次用户输入错误的密码、设置安全路径、配置自定义 sudo 日志文件等时发送邮件到 root。
|
||||||
|
|
||||||
|
保存并关闭文件。
|
||||||
|
|
||||||
|
使用 sudo 运行命令并输入错误的密码,然后观察 insults 选项是如何工作的:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo visudo
|
||||||
|
```
|
||||||
|
[
|
||||||
|

|
||||||
|
][4]
|
||||||
|
|
||||||
|
实践 sudo insult
|
||||||
|
|
||||||
|
注意:当配置 insults 参数时,它会禁用 `badpass_message` 参数,该参数会在命令行中输出特定的消息(默认消息为 “sorry, try again”),以防用户输入错误的密码。
|
||||||
|
|
||||||
|
要修改消息,请将 `badpass_message` 参数添加到 /etc/sudoers 文件中,如下所示。
|
||||||
|
|
||||||
|
```
|
||||||
|
Defaults badpass_message="Password is wrong, please try again" #try to set a message of your own
|
||||||
|
```
|
||||||
|
[
|
||||||
|

|
||||||
|
][5]
|
||||||
|
|
||||||
|
设置 sudo 错误密码消息
|
||||||
|
|
||||||
|
保存并关闭文件,然后调用 sudo 查看它是如何工作的,你设置的 badpass_message 消息会在每次你或任何系统用户输入错误的密码的时候打印出来。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo visudo
|
||||||
|
```
|
||||||
|
[
|
||||||
|

|
||||||
|
][6]
|
||||||
|
|
||||||
|
sudo 错误密码消息
|
||||||
|
|
||||||
|
就是这样了,在本文中,我们回顾了如何在用户输入错误的密码时将 sudo 设置为打印 insults。请通过下面的评论栏分享你的想法。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
作者简介:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Aaron Kili 是 Linux 和 F.O.S.S 爱好者,将来的 Linux SysAdmin、web 开发人员,目前是 TecMint 的内容创建者,他喜欢用电脑工作,并坚信分享知识。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
via: http://www.tecmint.com/sudo-insult-when-enter-wrong-password/
|
||||||
|
|
||||||
|
作者:[Aaron Kili][a]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:http://www.tecmint.com/author/aaronkili/
|
||||||
|
[1]:http://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/
|
||||||
|
[2]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
||||||
|
[3]:http://www.tecmint.com/wp-content/uploads/2017/01/Set-sudo-Insults-Parameter.png
|
||||||
|
[4]:http://www.tecmint.com/wp-content/uploads/2017/01/How-sudo-Insult-Works.png
|
||||||
|
[5]:http://www.tecmint.com/wp-content/uploads/2017/01/Set-sudo-badpassword-Message.png
|
||||||
|
[6]:http://www.tecmint.com/wp-content/uploads/2017/01/sudo-badpassword-Message.png
|
Loading…
Reference in New Issue
Block a user