I am using Paramiko to SSH and edit a config file. The file itself needs sudo permissions to edit. This hasn\'t been a problem so far, as I\'ve just done echo
If you read the error message
sudo: no tty present and no askpass program specified
then you can easily find the solution: add the -t
option to your ssh command:
-t
Force pseudo-terminal 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.
This has been discussed before:
Regarding Paramiko, there have been related questions, with a couple of different approaches:
Channel
to obtain a pseudo-terminal (which is analogous to telling ssh
to do this)-S
option of sudo
, and send the password on your standard output.For discussion, see the suggested answers here: