1

sudo -A ignoring SUDO_ASKPASS variable

I have been using sudo -A and SUDO_ASKPASS for years without trouble.

I have a newly installed Xubuntu Focal Fossa workstation and I cannot get sudo -A to work

I have:

me@mine:~$ cat .ssh/secrets/.supwd.sh
#!/bin/bash
echo 'SECRET'

me@mine:~$ ll .ssh/secrets/.supwd.sh -rwx------ 1 me me 27 Apr 25 10:25 .ssh/secrets/.supwd.sh*

me@mine:~$ cat .bash_profile SUDO_ASKPASS=${HOME}/.ssh/secrets/.supwd.sh

me@mine:~$ source .bash_profile

me@mine:~$ echo ${SUDO_ASKPASS} /home/me/.ssh/secrets/.supwd.sh

me@mine:~$ ${SUDO_ASKPASS} SECRET

me@mine:~$ sudo -A reboot now sudo: no askpass program specified, try setting SUDO_ASKPASS

me@mine:~$

What on earth have I forgotten?

Martin Bramwell
  • 265
  • 2
  • 11
  • 1
    Did you export it anywhere? what does declare -p SUDO_ASKPASS report? – steeldriver Apr 25 '21 at 14:46
  • GENIUS!!!! I change the .bash_profile line from SUDO_ASKPASS=${HOME}/.ssh/secrets/.supwd.sh to export SUDO_ASKPASS=${HOME}/.ssh/secrets/.supwd.sh and it works! Write it up as the answer and I'll do all the hearts and flowers stuff. Thank you!!! – Martin Bramwell Apr 25 '21 at 14:56

1 Answers1

2

The SUDO_ASKPASS variable needs to be exported to your environment, rather than defined as a simple shell variable:

export SUDO_ASKPASS=${HOME}/.ssh/secrets/.supwd.sh

or POSIXly

SUDO_ASKPASS=${HOME}/.ssh/secrets/.supwd.sh
export SUDO_ASKPASS
steeldriver
  • 136,215
  • 21
  • 243
  • 336