Closed kgn closed 11 years ago
I'm assuming that running commands with a pseudo-terminal would be enough to satisfy sudo.
There's no way to do this directly at the moment. There might be some incantation to bash or similar that opens a tty, but I don't know off the top of my head.
Actually implementing this in spur is fairly straightforward for SSH -- you can just call channel.get_pty
on the Paramiko Channel instance. Implementing this for local processes is a little trickier since it involves creating a pty using the pty
module, and then hooking it up the process created by Popen.
I've just added a use_pty
argument to run
and spawn
-- could you try seeing if setting it to True
does the trick? For instance:
shell = spur.SshShell(...)
shell.run(["sudo", "echo", "hello"], use_pty=True)
Hey sorry for the delay. I tried running this but it just hung, however I later found out this was due to a shell being opened that was waiting for the sudo password. Our sysadmin did something on the server with tty so it's working now but I cannot confirm if these changes would have gotten around the problem, sorry. Thanks for this update, hopefully it will help others.
Is there a way to run sudo commands remotely with spur?