Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I keep getting this error and have tried several ways discussed online to fix this and none are working for me. I have setup SSH keys so when I run 'ssh newton@host.com' it automatically logs me in, I have also set this user in visudo to be 'newton ALL=(ALL:ALL) ALL' I then also tried to add 'newton ALL=NOPASSWD: /var/www/script.sh'

Unfortunately everytime I run ssh newton@host.com 'sudo /var/www/script.sh' from cygwin I get back. I have also tried to add -t -t but then it prompts me for the password...

total size is 21209180  speedup is 314.69
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
share|improve this question

migrated from stackoverflow.com Sep 18 '12 at 23:46

This question came from our site for professional and enthusiast programmers.

    
This is not specific to Cygwin; I see the same problem using ssh example.com sudo echo hello from one Linux system to another. I've updated your title accordingly. I've also flagged your question for migration to the Unix site. –  Keith Thompson Sep 18 '12 at 21:33
    
I see thank you! –  user391986 Sep 18 '12 at 21:50

3 Answers 3

You need to have a terminal available to run sudo so that it can prompt you for the password. If you pass a command to ssh, it assumes that the command doesn't need a terminal and doesn't create one, unless you pass -t. See SSH inside SSH fails with "stdin: is not a tty" for a more detailed explanation.

If you aren't able to enter the password even with -t, it's possible that your problem is due to Windows. The Windows console does not completely emulate a unix terminal; there may be some difficulty for Cygwin applications to properly emulate a terminal in these circumstances (I'm not sure about that, note). If that's the problem, run ssh inside a terminal emulator such as Console2 or Mintty (included in the Cygwin distribution) — see Best way to use a shell with Cygwin in Windows 7.

If you expected the SSH passphrase to replace your password for authentication to sudo, that's not going to happen. Sudo requires a password (unless you add the NOPASSWD tag in the sudoers file). Note that you still need to have a terminal, even with NOPASSWD, if the requiretty option is set in the sudoers file.

If you want passwordless login up to the root account (which is generally not a good idea from a security perspective), use SSH to reach the root account, preferably in two hops. See SSH inside SSH fails with "stdin: is not a tty" (with root@host.com for otheruser@computertwo.com).

share|improve this answer

I faced this error when I made a mistake in /etc/sudoers. Instead of specifying multiple commands like this:

NOPASSWD= /bin/x, /bin/y

I saved as:

NOPASSWD= /bin/x /bin/y

i.e. without the comma. Now I get the no tty present message when I try

ssh host 'sudo x'
share|improve this answer

Don't know if it is related but when I had '...NOPASSWD: /xyz/script.shl' in the sudoers file, I got that error message until I included the #!/bin/shellname line at the top of the /xyz/script.shl file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.