473,394 Members | 1,841 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.

supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

Hi

I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)

I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?

Thanks.

Oct 5 '07 #1
7 4694
On Oct 5, 10:33 am, "timw.google" <tjand...@yahoo.comwrote:
Hi

I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)

I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?

Thanks.
I wrote a zsh script to do what I wanted, but I'd still like to know
how to do it in Python.

Oct 5 '07 #2
In message <11*********************@o80g2000hse.googlegroups. com>,
timw.google wrote:
I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password.
Why not set up a public/private SSH key pair between the accounts on the two
machines? Then you can get in without a password.

Oct 6 '07 #3
On 10/5/07, timw.google <tj******@yahoo.comwrote:
Hi

I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)

I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?
SSH takes measures to ensure that passwords are typed from a keyboard
(pty) rather than being piped in automatically (stdin).

If SSH public key authentication (see ssh-keygen) doesn't work for
you, then try ssh agent (see, ssh-add), "sshpass", or something like
"empty-expect".

If you use ssh public keys, you can also setup the public key so that
only a specified command can be run, and that the public key can only
be used from a specific host. This is more secure. See this page for
more info: http://troy.jdmz.net/rsync/index.html

Otherwise you may need to do some pty-hackery in python to fool ssh
into thinking it's password is being entered from a keyboard and not a
script. However, you should try public key authentication (with rsync
as the only allowed command) first.

Another method is to setup an ssh service on the server (perhaps in
inetd). One disadvantage of this is that the rsync session (including
rsync login passwords) is not encrypted.
Oct 7 '07 #4
Typo.
Another method is to setup an ssh service on the server (perhaps in
Should be:
Another method is to setup an rsync service on the server (perhaps in
Oct 7 '07 #5
timw.google wrote:
Hi

I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)

I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?
You need to use the pexpect module.
>
Thanks.
Oct 7 '07 #6
On 05 Oct 2007 16:23:50 GMT, Stargaming <st********@gmail.comwrote:
On Fri, 05 Oct 2007 08:37:05 -0700, timw.google wrote:
I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?

Thanks.
I wrote a zsh script to do what I wanted, but I'd still like to know how
to do it in Python.

`subprocess.Popen` has a keyword argument called `stdin` -- what takes
the password, I guess. Assigning `subprocess.PIPE` to it and using
`Popen.communicate` should do the trick.
SSH doesn't read passwords off of stdin. If you want to supply a
password to SSH, then you need to control a pty directly.

--
Nick
Oct 8 '07 #7
On Oct 7, 1:01 pm, Michael Torrie <torr...@chem.byu.eduwrote:
timw.google wrote:
Hi
I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)
I can't ssh w/o supplying a password. That's the way the security is
set up here.
How do I use python to do this, or do I just have to write a zsh
script?

You need to use the pexpect module.
Thanks.
Thanks to all the suggestions on getting this to work w/ python. I'll
look into this more when I get the chance. I don't have root access,
so setting up some kind of server is out. I may not be able to try the
other suggestions either, as they have things locked down pretty tight
around here.

Oct 9 '07 #8

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

Similar topics

36
by: dcrespo | last post by:
Hi all, I have a program that serves client programs. The server has a login password, which has to be used by each client for logging in. So, when the client connects, it sends a string with a...
3
by: Mike Wiseley | last post by:
I created a desktop shortcut with "C:\Program Files\Microsoft Office\MSAccess.exe" "C:\My Documents\CopyAToB.mdb" /pwd "password: The trouble is that when running this shortcut, it prompts first...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
3
by: Darren Dale | last post by:
I'm a developer on the matplotlib project, and I am having trouble with the subprocess module on windows (Python 2.4.2 on winXP). No trouble to report with linux. I need to use _subprocess instead...
5
by: Vincent Pirez | last post by:
Hi, Has anyone managed to code anything that will verify the username and password of a user against the /etc/shadow file? I need to authenticate users based on their local system accounts,...
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
2
by: Rafael Giannetti Viotti | last post by:
Hi, I am working with the subprocess.py module in Python 2.4.4 and I am confused about it's functionality. It uses the standard pipe-fork-exec method to start a subprocess: # create pipes ...
2
by: =?Utf-8?B?c3RhZ2VybGVp?= | last post by:
We would like to change the password for the ASPNET account on our W2k3 servers running IIS 6.0 and .NET 1.1. Will we run into problems? Is there a way to determine the current password, in case...
12
by: bhunter | last post by:
Hi, I've used subprocess with 2.4 several times to execute a process, wait for it to finish, and then look at its output. Now I want to spawn the process separately, later check to see if it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.