您可以在的帮助下通过GUI提示符询问密码-A, --askpass。
从联机帮助页:
-A, --askpass
                 Normally, if sudo requires a password, it will read it from the user's terminal.  If the -A
                 (askpass) option is specified, a (possibly graphical) helper program is executed to read the user's
                 password and output the password to the standard output.  If the SUDO_ASKPASS environment variable
                 is set, it specifies the path to the helper program.  Otherwise, if sudo.conf(5) contains a line
                 specifying the askpass program, that value will be used.  For example:
                     # Path to askpass helper program
                     Path askpass /usr/X11R6/bin/ssh-askpass
                 If no askpass program is available, sudo will exit with an error.
所以,你可以图形化的辅助程序,如ssh-askpass它会提示输入密码短语用户使用GNOME:
$ which ssh-askpass
/usr/bin/ssh-askpass
因此,将以下行添加到/etc/sudo.conf:
# Path to askpass helper program
Path askpass /usr/bin/ssh-askpass
您会发现GUI密码提示:

您也可以zenity为此使用其他程序。我使用以下示例:
$ cat /etc/sudo.conf
# Path to askpass helper program
Path askpass /usr/local/bin/zenity_passphrase
zenity_passphrase自定义脚本集在哪里设置,可以直接用作命令:
$ cat $(which zenity_passphrase)
#!/bin/bash
zenity --password --title="sudo password prompt" --timeout=10
像这样工作:

注意: 
               
              
pkexec leafpad,当使用pkexec时,它Cannot open display:在输入密码后给出。是否需要其他配置?