set environment variable SSH_ASKPASS or askpass in sudoers, resp

jan picture jan · Apr 19, 2012 · Viewed 38.8k times · Source

I'm trying to login to a ssh server and to execute something like:

ssh [email protected] 'sudo echo "foobar"'

Unfortunately I'm getting an error:

sudo: no tty present and no askpass program specified

Google told me to either set the environment variable SSH_ASKPASS or to set askpass in the sudoers file. My remote machine is running on Debian 6 and I've installed the packages ssh-askpass and ssh-askpass-gnome and my sudoers file looks like this:

Defaults        env_reset
Defaults        askpass=/usr/bin/ssh-askpass

# User privilege specification
root    ALL=(ALL) ALL
user    ALL=(ALL) ALL

Can someone tell what I'm doing wrong and how to do it better.

Answer

nosid picture nosid · Apr 19, 2012

There are two ways to get rid of this error message. The easy way is to provide a pseudo terminal for the remote sudo process. You can do this with the option -t:

ssh -t [email protected] 'sudo echo "foobar"'