使用 gnome-terminal 保持 sudo 身份验证

使用 gnome-terminal 保持 sudo 身份验证

会话是否可以sudo在 的选项卡之间共享gnome-terminal,这样一旦我sudo在一个选项卡中使用,我就不必在每次打开另一个选项卡并使用 时重新输入密码sudo

答案1

共享sudo身份验证全部shell 会话(不仅仅是特定gnome-terminal实例的选项卡),您需要将此行添加到您的/etc/sudoers文件中(用于visudo执行此操作):

Defaults !tty_tickets

man sudoers

   sudoers uses time stamp files for credential caching.  Once a user has
   been authenticated, a time stamp is updated and the user may then use
   sudo without a password for a short period of time (15 minutes unless
   overridden by the timeout option.  By default, sudoers uses a tty-based
   time stamp which means that there is a separate time stamp for each of
   a user's login sessions.  The tty_tickets option can be disabled to
   force the use of a single time stamp for all of a user's sessions.

   [...]

   tty_tickets     If set, users must authenticate on a per-tty basis.
                   With this flag enabled, sudo will use a file named for
                   the tty the user is logged in on in the user's time
                   stamp directory.  If disabled, the time stamp of the
                   directory is used instead.  This flag is on by default.

相关内容