Skip to main content

What option should I give the sudo command to have the password asked troughthrough a graphical interface?

Tweeted twitter.com/#!/StackApple/status/108202485335863297
Source Link
apouche
  • 500
  • 2
  • 6
  • 11

What option should I give the sudo command to have the password asked trough graphical interface?

This problem has ben bugging me for a while now.

Every now and then, I need to write a script file that should execute sudo commands. I do not necessarily know in advance that I will run as sudo so I am sure there is a way to open a nice graphical interface (such as the one popping up when installing software) but how ?

The man sudo says:

-A          Normally, if sudo requires a password, it will read it from the current 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, the value specified by the askpass option in
            sudoers(5) is used

So I am pretty sure the solution resides in that -A and SUDO_ASKPASS tuple however I've managed to find what to put into those.