Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  102] [ 0]  / answers: 1 / hits: 317991  / 1 Year ago, thu, december 29, 2022, 11:02:03

When attempting to run a remote binary using sudo on the remote box:

ssh remotehost "sudo ./binary"

I see this error:

sudo: no tty present and no askpass program specified

How can I work around this?

More From » ssh


A simple way is to specify -t:

ssh -t remotehost "sudo ./binary"

From the man page:

Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

I cannot explain exactly why this works, and there may be a better way. I'd like to hear about it if so :)

@psusi explains why this works in a comment below.

[#31749] Friday, December 30, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 9
Total Questions: 102
Total Answers: 118

Location: Tajikistan
Member since Tue, Mar 21, 2023
1 Year ago