ssh popen stalling on password redirect output?

S

supercomputer

I have a script that I cycle through nodes connect to them and run
uptime to get some information. I run the script as root so it doesn't
require a password on the rest of the nodes. It does however barf on
the nodes that are having trouble and require a different password. Is
there an easy way to skip these nodes? Maybe redirect the password
prompt to stdout or stderr or even skip them?

Thanks in advance here is the current script.

info=os.popen('ssh node208 uptime')
sys.stderr=info
sys.stderr.write(info)

I'm very new to python if you could give me a link to an article that
would also be helpful. The documentation on python is very hard to
find as compared with php.net's php documentation.
 
S

Sybren Stuvel

(e-mail address removed) enlightened us with:
I have a script that I cycle through nodes connect to them and run
uptime to get some information. I run the script as root so it
doesn't require a password on the rest of the nodes. It does
however barf on the nodes that are having trouble and require a
different password. Is there an easy way to skip these nodes?
Maybe redirect the password prompt to stdout or stderr or even skip
them?

Why not set up proper public/private key authentication, and don't
bother with passwords at all?

Sybren
 
J

Jeff Epler

In your ssh configuration, specify something like
PreferredAuthentication "hostbased,publickey"
this will skip trying to use the methods called keyboard-interactive and
password.

You can give this flag on the ssh commandline, too. read the ssh(1) and
ssh_config(5) manpages for more information.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFC2GhQJd01MZaTXX0RAthiAJ4pehS1BbGD7KQuQqz9TbYbuzWXJgCfR9fb
NWbzgCJ6AZ01MW+UIXTM/Ys=
=CcB8
-----END PGP SIGNATURE-----
 
C

Cantankerous Old Git

In general, it is good idea to use expect kind of tool to deal with
interactive programs like ssh. You may try using pexpect
(http://pexpect.sourceforge.net).

I tried tha once (on Solaris) and found that ssh could tell that
pexpect wasn't a real tty and refused to connect. In the end, I
had pexpect do a telnet 127.0.0.1, log in, then so ssh to the
real destination. Pain in the ass but it worked.

The Cog
 
C

Cameron Laird

I tried tha once (on Solaris) and found that ssh could tell that
pexpect wasn't a real tty and refused to connect. In the end, I
had pexpect do a telnet 127.0.0.1, log in, then so ssh to the
real destination. Pain in the ass but it worked.

The Cog

1. Pexpect is designed to do better than this. Please
report specific deficiencies in its operation.
2. (The original) Expect has had years of working out
pty vagaries. In a pinch, I'd write in Expect, and,
if necessary, control the Expect process from Python.
 
S

supercomputer

Thanks for the help, this gives me a few options. I think the best way
to do it is using the public/private key authentication.
 
S

supercomputer

Thanks for the help, this gives me a few options. I think the best way
to do it is using the public/private key authentication.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,261
Messages
2,571,308
Members
47,976
Latest member
AlanaKeech

Latest Threads

Top