sudo: no tty present and no askpass program specified

After upgrading Windows subsystem for Linux from Ubuntu 14.04 to 16.04 I was getting the following:
mjs@IMAGE:/mnt/c/Users/mjs/Desktop$ sudo hostname localhost
sudo: unable to resolve host IMAGE
sudo: no tty present and no askpass program specified

The hostname needed to be set to localhost and I obviously needed to be able to enter a password.
But, in order to hostname, I needed to either use sudo or su.
I tried su and the password was set but not what it was prior to the upgrade 🙁

man sudo came to the rescue as man pages so often do.

mjs@IMAGE:/mnt/c/Users/mjs/Desktop$ sudo -S -h localhost hostname localhost
[sudo] password for mjs:

-h localhost solves the hostname problem by temporarily specifying the hostname.
-S requests that sudo use stdin for the password request which solves the askpass problem.

The next task was to edit /etc/hostname to contain localhost to make it permanent and to use sudo to change the root password.

Hope this helps,


Leave a Reply

Your email address will not be published. Required fields are marked *