[Twisted-Python] How to switch users in SSH session.
paulswartz at gmail.com
Wed Oct 3 11:02:06 EDT 2007
On 9/28/07, Jean-Paul Calderone <exarkun at divmod.com> wrote:
> On Thu, 27 Sep 2007 15:00:14 -0500, paul_s_johnson at mnb.uscourts.gov wrote:
> >Here's the line that instaniates my SSH object (also repeated at the end
> >of my code):
> >myssh = SSH("my.host.com", "myusername", "mypasswd", ["id; su - root;
> >myrootpasswd; id", "pwd", "ls -l"])
> I suspect the list element which includes "su - root; myrootpasswd;"
> won't achieve the desired affect. Even if su weren't careful to try
> to read from a pty, "myrootpasswd" won't be sent to its stdin, it'll
> be executed by the shell after "su - root" exits, which it probably
> won't since nothing is going to write a password to it.
What you'll do is on the channel object which runs these commands,
you'll use the .write() method to send the root password to su.
paulswartz at gmail dot com
More information about the Twisted-Python