reading unix files from NT using SSH2

Noah noah at noah.org
Tue Apr 23 16:59:57 EDT 2002


Take a look at PuTTY. This is a free SSH client for Windows.
	http://www.chiark.greenend.org.uk/~sgtatham/putty/
Ignore the fact that it's Beta. It's been out for a long time and
it is stable. PuTTY has a few different tools.
You might want to check out Plink:
	http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter7.html#7

Another possibility is to try Cygwin. It comes with SSH and SCP/
	http://www.cygwin.com/

The other trick you will need to master is using Public Key authentication.
See the man pages for ssh-keygen. You need to use public keys instead of 
passwords in order to use SSH in a script. You can't easily automate giving
SSH or SCP a password from inside a script. Public Keys takes care of this
while preserving security. It only takes a few steps to setup, but 
it sometimes confuses people the first time. Email me if you need help.
Once you get the keys setup then it just works.

Then from Python you could do something like this.
This will copy a file onto the desktop (for all users to see).

	os.system(r'C:\cygwin\bin\scp.exe remotehost:/tmp/mydata 
		"//c/Documents and Settings/All Users/Desktop/mydata.txt"')

Note the raw string
	r'C:\cygwin ... '
This is because we need to give os.system a Windows path name 
that includes backslashes. Without the r'raw string' Python would get confused.
Also note that for scp.exe you need to use Cygwin's style for 
referring to Windows paths. It is also "quoted" because of the 
spaces in the path name.
	"//c/Documents and Settings/All Users/Desktop/mydata.txt"

Yours,
Noah


-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of James Strater
Sent: Tuesday, April 23, 2002 7:32 AM
To: python-list at python.org
Subject: reading unix files from NT using SSH2


I have a python script running on an NT box.  I need to connect to a  unix
box using SSH2 and read some files sitting on that box.  Can anyone point me
in the right direction on how to go about doing this?   The script needs to
stay on the NT box so that it can do some things with MS Excel using COM.  

Thanks,

James








More information about the Python-list mailing list