[paramiko] Handling sudo

Justin Cook jhcook at gmail.com
Tue Feb 26 05:55:39 PST 2008


There are a couple ways I can see to do it readily offhand. One, I
haven't figured out how to receive the sudo password prompt yet.
Apparently, it writes the password prompt to a terminal device. So,
you should be able to set an alarm and send the password down the
channel in event there is no response from the command. This is dirty
IMO.

Secondly, and perhaps more clean to use in conjunction with the first
option, is to use the -k or -K option to invalidate the sudo timestamp
and thus requiring to send the password on every invocation and not
worry about whether or not you've been prompted. However, this isn't
very clean either in case no password is required.

Not a good solution in either respect in my opinion. If this can be
done easily with SSHClient someone shoot me in the foot!

On Tue, Feb 26, 2008 at 12:10 PM, Jon Sabo <jonathan.sabo at gmail.com> wrote:
> Justin,
>
>  If you make this work please let me know.  I need to be able to do the
>  same thing.  Usually people will just say use sudo with the no passwd
>  option or use pexpect or something...


-- 
Justin Cook



More information about the paramiko mailing list