Chris Rogers Chris Rogers - 1 month ago 49
Linux Question

Windows Bash (WSL) - sudo: no tty present and no askpass program specified

After following this tutroial I get the following error when trying to run the commands as user or even sudo:


sudo: no tty present and no askpass program specified


The comments from Lurdan in this article state that you need to run

sudo -S <YOUR_COMMAND>
chmod 0666 /dev/tty


chmod
doesn't work but
sudo -S
does, but surely there's another fix?

Answer

So silly, after looking further down I see a solution from Beorat:

To avoid the sudo tty issue and others, run these commands just before running do-release-upgrade:

sudo -S apt-mark hold sudo
sudo -S apt-mark hold procps
sudo -S apt-mark hold strace

If you've already upgraded, run the above commands, then manually downgrade to the Trusty packages:

sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.2_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2.2_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb
sudo -S dpkg -i sudo_1.8.9p5-1ubuntu1.2_amd64.deb
sudo -S dpkg -i procps_3.3.9-1ubuntu2.2_amd64.deb
sudo -S dpkg -i strace_4.8-1ubuntu5_amd64.deb

More info here: https://github.com/Microsoft/BashOnWindows/issues/482