如何在 Linux 中不输入密码运行 sudo 命令

此设置在 /etc/sudoers
文件中完成,这是使用 sudo 命令的默认安全策略;在用户权限指定部分。
重要:在 sudeors
文件中,默认打开的 authenticate
参数用于验证目的。如果设置了它,用户必须通过密码(或其他身份验证方法)进行身份验证,然后才能使用 sudo
运行命令。
但是,可以使用 NOPASSWD
(当用户调用 sudo
命令时不需要密码)标记来覆盖此默认值。
配置用户权限的语法如下:
user_list host_list=effective_user_list tag_list command_list
其中:
user_list
- 用户列表或已经设置的用户别名。host_list
- 主机列表或用户可以在其上运行 sudo 的主机别名。effective_user_list
- 以该用户或别名运行的用户列表tag_list
- 标签列表,如NOPASSWD
。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
不用密码运行 sudo
对于更多的 sudo
配置和其他使用选项,请阅读我们有更多例子描述的文章,:
在本篇中,我们讨论了如何配置 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 译者:geekpi 校对:jasminepeng
本文转载来自 Linux 中国: https://github.com/Linux-CN/archive
350fairfax nordvpn promo code
Howdy I am so thrilled I found your webpage, I really found you
by accident, while I was researching on Askjeeve for something else, Regardless I am
here now and would just like to say thank you for a marvelous post and a all round entertaining blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have book-marked it and also included your RSS feeds,
so when I have time I will be back to read more,
Please do keep up the excellent b.
Pretty nice post. I just stumbled upon your weblog and wanted to say that
I’ve really enjoyed surfing around your blog
posts. In any case I will be subscribing to your rss feed
and I hope you write again soon!
my webpage :: nordvpn coupons inspiresensation
With havin so much content do you ever run into any problems of plagorism or copyright violation?
My blog has a lot of exclusive content I’ve either authored myself or outsourced but it
looks like a lot of it is popping it up all over the web without my agreement.
Do you know any methods to help protect against content from being stolen? I’d definitely appreciate it.
Review my blog post; nordvpn coupons inspiresensation
This design is spectacular! You obviously know how to
keep a reader amused. Between your wit and your videos, I was
almost moved to start my own blog (well, almost…HaHa!) Great job.
I really enjoyed what you had to say, and more
than that, how you presented it. Too cool!
Here is my website :: nordvpn coupons Inspiresensation
Great post. I was checking constantly this weblog and I am impressed!
Very helpful info particularly the closing phase
I deal with such information much.
I used to be seeking this certain information for a very long time.
Thanks and best of luck.
Also visit my web site; nordvpn coupons inspiresensation