延长sudo密码时限

默认状态下sudo执行命令之后的15分钟再次使用sudo使用命令需要再次输入密码绝大多数情况这个时间通过对sudoers文件修改可以延长sudo密码时限

以下为man手册对sudoers文件描述

The sudoers file is composed of two types of entries: aliases (basically variables) and user specifications (which specify who may run what).
When multiple entries match for a user, they are applied in order. Where there are multiple matches, the last match is used (which is not necessarily the most specific match).
The sudoers grammar will be described below in Extended Backus Naur Form (EBNF).Don’t despair if you don’t know what EBNF is; it is fairly simple, and the defi-nitions below are annotated.

延长sudo时限需要在/etc/sudoers任意位置添加一句

Defaults:swift timestamp_timeout=0

其中数字代表希望sudo记录时间长度。0记录如果为-1代表sudo永远记住密码直到重启

sudoers文件还有很多其他选项可用于对sudo命令相关进行配置详细操作方法可以在man手册查到

—————————

P.S.如果觉得将timestamp_timeout设置为-1安全可以执行命令或者离开电脑执行sudo -k停止当前时间戳下次执行sudo再次提示输入密码

如果你喜欢这篇日志的话,欢迎订阅我的RSS Feed!
本文来源于一阁Blog。版权所有,转载请确保已阅读该页面

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Quote selected text






网站备案中

Valid XHTML 1.1