mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-24 02:20:09 +08:00
commit
839a40be68
@ -1,95 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
How to Run ‘sudo’ Command Without Entering a Password in Linux
|
||||
============================================================
|
||||
|
||||
In case you are running Linux on a machine that you normally use alone, say on a laptop, entering a password each time you invoke **sudo** can become so boring in the long run. Therefore, in this guide, we will describe [how to configure sudo command][4] to run without entering a password.
|
||||
|
||||
This setting is done in the **/etc/sudoers** file, which drives sudoers to use default security policy plugin for the [sudo command][5]; under the user privilege specification section.
|
||||
|
||||
**Important**: In the **sudeors** file, the authenticate parameter which is turned on by default is used for authentication purposes. If it is set, users must authenticate themselves via a password (or other means of authentication) before they run commands with **sudo**.
|
||||
|
||||
However, this default value may be overridden using the **NOPASSWD** (require no password when user invokes **sudo** command) tag.
|
||||
|
||||
The syntax to configure user privileges is as follows:
|
||||
|
||||
```
|
||||
user_list host_list=effective_user_list tag_list command_list
|
||||
```
|
||||
|
||||
Where:
|
||||
|
||||
1. `user_list` – list of users or a user alias that has already been set.
|
||||
2. `host_list` – list of hosts or a host alias on which users can run sudo.
|
||||
3. `effective_user_list` – list of users they must be running as or a run as alias.
|
||||
4. `tag_list` – list of tags such as NOPASSWD.
|
||||
5. `command_list` – list of commands or a command alias to be run by user(s) using sudo.
|
||||
|
||||
To allow a user (`aaronkilik` in the example below) to run all commands using **sudo** without a password, open the **sudoers** file:
|
||||
|
||||
```
|
||||
$ sudo visudo
|
||||
```
|
||||
|
||||
And add the following line:
|
||||
|
||||
```
|
||||
aaronkilik ALL=(ALL) NOPASSWD: ALL
|
||||
```
|
||||
|
||||
For the case of a group, use the `%` character before the group name as follows; this means that all member of the `sys` group will run all commands using sudo without a password.
|
||||
|
||||
```
|
||||
%sys ALL=(ALL) NOPASSWD: ALL
|
||||
```
|
||||
|
||||
To permit a user to run a given command (`/bin/kill`) using sudo without a password, add the following line:
|
||||
|
||||
```
|
||||
aaronkilik ALL=(ALL) NOPASSWD: /bin/kill
|
||||
```
|
||||
|
||||
The line below will enable member of the `sys` group to run the commands: **/bin/kill**, **/bin/rm**using **sudo** without a password:
|
||||
|
||||
```
|
||||
%sys ALL=(ALL) NOPASSWD: /bin/kill, /bin/rm
|
||||
```
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
Run sudo Without Password
|
||||
|
||||
For more **sudo** configuration and additional usage options, read our articles that describes more examples:
|
||||
|
||||
1. [10 Useful Sudoers Configurations for Setting ‘sudo’ in Linux][1]
|
||||
|
||||
3. [Let Sudo Insult You When You Enter Incorrect Password][2]
|
||||
4. [How to Keep ‘sudo’ Password Timeout Session Longer in Linux][3]
|
||||
|
||||
In this article, we described how to configure sudo command to run without entering a password. Do not forget to offer us your thoughts about this guide or other useful sudeors configurations for Linux system administrators all in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
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/run-sudo-command-without-password-linux/
|
||||
|
||||
作者:[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/sudo-insult-when-enter-wrong-password/
|
||||
[3]:http://www.tecmint.com/set-sudo-password-timeout-session-longer-linux/
|
||||
[4]:http://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/
|
||||
[5]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/01/Run-sudo-Without-Password.png
|
@ -0,0 +1,92 @@
|
||||
如何在 Linux 中运行 “sudo” 命令不用输入密码
|
||||
============================================================
|
||||
|
||||
如果你在计算机上运行 Linux 系统,比如在笔记本电脑上,在每次调用 **sudo** 时需要输入密码,从长远来看都会变得无聊。因此,在本指南中,我们将描述[如何配置 sudo 命令][4]在运行时而不输入密码。
|
||||
|
||||
此设置在 **/etc/sudoers** 文件中完成,它让 sudoers 使用 [sudo 命令][5]的默认安全策略; 在用户权限指定部分。
|
||||
|
||||
**重要**:在 **sudeors** 文件中,默认打开的 authenticate 参数用于验证目的。如果设置,用户必须通过密码(或其他身份验证方法)进行身份验证,然后才能使用 **sudo** 运行命令。
|
||||
|
||||
但是,可以使用 **NOPASSWD**(当用户调用 **sudo** 命令时不需要密码)标记来覆盖此默认值。
|
||||
|
||||
配置用户权限的语法如下:
|
||||
|
||||
```
|
||||
user_list host_list=effective_user_list tag_list command_list
|
||||
```
|
||||
|
||||
这里是:
|
||||
|
||||
1. `user_list` - 用户列表或已经设置的用户别名。
|
||||
2. `host_list` - 主机列表或用户可以在其上运行 sudo 的主机别名。
|
||||
3. `effective_user_list` - 目标用户
|
||||
4. `tag_list` - 标签列表,如 NOPASSWD。
|
||||
5. `command_list` - 用户使用 sudo 运行的命令或命令别名列表。
|
||||
|
||||
要允许用户(下面的示例中的 “aaronkilik”)使用 **sudo** 而不使用密码运行所有命令,请打开 **sudoers** 文件:
|
||||
|
||||
```
|
||||
$ sudo visudo
|
||||
```
|
||||
|
||||
添加下面的行:
|
||||
|
||||
```
|
||||
aaronkilik ALL=(ALL) NOPASSWD: ALL
|
||||
```
|
||||
|
||||
对于组而言,在组名前面使用`%`字符;这意味着 `sys` 组的所有成员都可以不用密码使用 sudo。
|
||||
|
||||
```
|
||||
%sys ALL=(ALL) NOPASSWD: ALL
|
||||
```
|
||||
|
||||
要不用密码使用 sudo 运行指定命令(`/bin/kill`),添加下面的行:
|
||||
|
||||
```
|
||||
aaronkilik ALL=(ALL) NOPASSWD: /bin/kill
|
||||
```
|
||||
|
||||
下面的行会让 `sys` 组在使用 **sudo** 运行命令:**/bin/kill**、**/bin/rm** 时不用输入密码:
|
||||
|
||||
```
|
||||
%sys ALL=(ALL) NOPASSWD: /bin/kill, /bin/rm
|
||||
```
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
不用密码运行 sudo
|
||||
|
||||
对于更多的 **sudo** 配置和额外的使用选项,阅读我们的文章,描述了更多了例子:
|
||||
|
||||
1. [在 Linux 中设置 ‘sudo’ 10 个有用的 sudoers 配置][1]
|
||||
2. [让 sudo 在你输入错误密码时候嘲讽你][2]
|
||||
3. [如何在 Linux 中让 “sudo” 密码超时会话更长][3]
|
||||
|
||||
在本篇中,我们讨论了如何配置 sudo 命令来不用输入密码运行。不要忘记在评论栏中给我们提供你关于这份指导的想法和其他对于 Linux 系统管理员有用的 sudoers 配置。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
作者简介:
|
||||
|
||||
Aaron Kili 是 Linux 和 F.O.S.S 爱好者,将来的 Linux SysAdmin 及 web 开发者,目前是 TecMint 的内容创作者,他喜欢用电脑工作,并坚信分享知识。
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
|
||||
via: http://www.tecmint.com/run-sudo-command-without-password-linux/
|
||||
|
||||
作者:[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/sudo-insult-when-enter-wrong-password/
|
||||
[3]:http://www.tecmint.com/set-sudo-password-timeout-session-longer-linux/
|
||||
[4]:http://www.tecmint.com/sudoers-configurations-for-setting-sudo-in-linux/
|
||||
[5]:http://www.tecmint.com/su-vs-sudo-and-how-to-configure-sudo-in-linux/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2017/01/Run-sudo-Without-Password.png
|
Loading…
Reference in New Issue
Block a user