On Thu, 27 Sep 2007 15:00:14 -0500, paul_s_johnson@mnb.uscourts.gov wrote:
After much wrangling and a small miracle I have managed to write an object that fetches the output of three commands in the order given through an SSH connection. How come I cannot switch users? Some of the information I need can only be fetched through a root account and security is such that I cannot log in remotely from a root account but must switch once logged in from an account with less than root privileges.
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. Instead, you probably need to send the password over the connection after "su - root" has started and is waiting for the password. I'm not exactly sure what the steps to this in detail are, though. Jean-Paul