473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ssh popen stalling on password redirect output?

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.

Jul 21 '05 #1
8 4099
su***********@gmail.com 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
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa
Jul 21 '05 #2

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).

Jul 21 '05 #3
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)

iD8DBQFC2GhQJd01MZaTXX0RAthiAJ4pehS1BbGD7KQuQqz9Tb YbuzWXJgCfR9fb
NWbzgCJ6AZ01MW+UIXTM/Ys=
=CcB8
-----END PGP SIGNATURE-----

Jul 21 '05 #4
dr*******@gmail.com wrote:
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
Jul 21 '05 #5
In article <db**********@news.freedom2surf.net>,
Cantankerous Old Git <Ca****************@gmail.com> wrote:
dr*******@gmail.com wrote:
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


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.
Jul 21 '05 #6
P
for ssh automation I would in order:

paramiko
twisted
keys + popen
pexpect

--
Pádraig Brady - http://www.pixelbeat.org
--
Jul 21 '05 #7
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.

Jul 21 '05 #8
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

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: M | last post by:
Hi Folks, I would like to use popen and redirect output from a program, except it doesn't seem to work. I am using IIS 5.1 on Windows XP Pro. Error messages are as follows: Warning:...
4
by: Ivo Woltring | last post by:
Hi Pythoneers, I am trying to make my own gui for mencoder.exe (windows port of the terrific linux mencoder/mplayer) to convert divx to Pocket_PC size. My current app creates a batch script to...
1
by: sam | last post by:
Hi, I try to use popen execute scp, when the user finish password, it will return to the cin input prompt, but the problem is popen does not wait for user finish typing up the password before...
2
by: Maarten van Veen | last post by:
A long story made short, I've build a python/cgi website consisting of two pages. Page1 has a html form in which you can input a series of queries. Then via Popen it starts a pythons search script,...
5
by: damacy | last post by:
hello, everyone. i am trying to write a program which executes SQL commands stored in ..sql files. i wrote a function called psql() whose contents look like the following. .......
4
by: Kevin Walzer | last post by:
I'm trying to structure a Python script that streams output over a pipe. Here is my code: import os cmd = os.popen('echo foo | sudo -S /usr/sbin/tcpdump -en1') cmd.read() This returns...
1
by: Kevin Walzer | last post by:
I'm trying to display the output of an external process (invoked via popen) in a Tkinter text widget. I successfully start the process (based on what I'm seeing in my terminal output), but I can't...
13
by: bayer.justin | last post by:
Hi, I am trying to communicate with a subprocess via the subprocess module. Consider the following example: <subprocess.Popen object at 0x729f0> Here hey is immediately print to stdout of...
2
by: rparimi | last post by:
I am trying to redirect stderr of a process to a temporary file and then read back the contents of the file, all in the same python script. As a simple exercise, I launched /bin/ls but this doesn't...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.