On 8/10/05, Bernard Lebel <[EMAIL PROTECTED]> wrote: > Hello, > > I'm trying to make a script to send a SSH command from a Linux > computer to another Linux compter. > > The Python syntax I'm using... > > > import os > os.system( 'ssh [EMAIL PROTECTED] "ls"' ) > > > Now the problem is that I'm always asked for the password. So my > question is two-fold: > > 1- Is there a way to not be asked for the root password? > 2- If not, then is it possible to feed the SSH password input with my > Python script? I have about stdin redirection, but I have to admit > that I'm a bit lost and I don't know if it applies to SSH input as > well. > > Right now I'm using the ls command to list processes, however > ultimately I want to be able to kill some processes within a loop > (this is for render farm management). > > > > Thanks > Bernard
Some of the things you are going to be bit by you've already ran into - the first of which is authentication. I would recommend looking at the following utilities: http://www.theether.org/pssh/ http://sourceforge.net/projects/pyssh Setting up private/public key authentication is going to allow for a greate amount of secure automation. Barring that, use the pexpect module to do the prompt handling, pexpect is bad simply due to the fact you'll need to store your passwords plaintext within your program which is a seriously risk. Also note you'll need to take into account basic flow control for Stdin, Stdout and Stderr - you need to watch for hosts that are not found/don't exist and ssh commands that may or may not hang. The PSSH program has excellent work arounds for all of these within it. -jesse _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor