Vagrant, PhpStorm and the “sudo: no tty present and no askpass program specified” error

Well, this is a wordy headline. But if you are running into this problem – like I did – you might search exactly for this and this is called effective seo or something. Here is the premise: You are using Vagrant, like any self-respecting developer would do and you also have soft spot for JetBrains products, i.e. PhpStorm, then you might want to start and stop vagrant directly from your beloved IDE. As you should! You paid good money to be spared from entering commands into a terminal.

These buttons were expensive. So I will use them!

These buttons were expensive. So I will use them!

But there is a catch: In case some commands are triggered during that process that require sudo privileges – like the awesome hostupdater-script – you will be greeted by the following message:

sudo: no tty present and no askpass program specified

Now what? I have read some suggestions, that you should change your sudoers configuration, but that doesn’t seem right. I found a simple solution inside PhpStorm. Go to Settings->Tools->Vagrant and add SUDO_ASKPASS=/usr/bin/ssh-askpass to the “Environment variables”.

Change the "Environment variables" to this and you will be asked for the sudo password whenever it is needed.

Change the “Environment variables” to this and you will be asked for the sudo password whenever it is needed.

And next time your sudo password is needed, you will be asked to enter it. On my system, that looks like this:

Thanks OpenSSH! I can now enter my sudo password with ease!

Thanks OpenSSH! I can now enter my sudo password with ease!

Ain’t that neat? Of course, if you use Windows or iOS, you might have to adapt the variable accordingly (read: I have no idea what you should do, you’re on your own, buddy).

Hope that helps!

4 comments

Leave a Reply to Daniel Röhrig Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.