From: Mark W. A. <sl...@do...> - 2004-12-08 20:03:15
|
On Tue, Dec 07, 2004 at 08:39:30PM -0800, Jay H wrote: > Hi All, > > I just joined the list. I really need to find examples of how to use > pyssh to perform scp file transfers with a password. I downloaded the > pyssh files and ran the setup.py but I can't find any examples of how > to use the code. Could someone show how to effect an scp transfer, > for instance > > scp ro...@my...:/usr/local/tmp/* . > > with the pyssh module? Welcome! I've only recently took over as maintainer, but from what I can see there is no "real" support for scp at all. I suspect no effort has been expended because it's really as simple as: import os os.system("scp ro...@my...:/usr/local/tmp/* .") This will trigger the default passphrase/password interaction, just as if you had done the scp from the command line. If you want to do an scp withOUT a password, you can use ssh-agent and keys. You can use the new fssa module to have a batch/cron job connect to a running agent (see http://www.ucolick.org/~sla/ssh/sshcron.html for the mechanics). To do this with pyssh: import pyssh, os pyssh.fssa.fssa() os.system("scp ro...@my...:/usr/local/tmp/* .") ("from pyssh.fssa import fssa" also works fine if that's all you need.) The call to fssa() will find a running agent for the executing user and attach to it. Since you want to access the remote machine as root, you really should use keys. It's best to not allow any root access via ssh. It's better to only allow root access with keys. It's not real safe (least best? - but better than non-ssh alternatives) to allow root access with password access (the "defense in depth" security principle). Note that it's possible to have a "user" key allowed to ssh to root by putting the user key in root's "authorized_keys" file. (Something I wouldn't do on the big, bad, Internet but I do to certain machines on my home network ;) If this is not what you're looking for, let me know how you'd like it to work and we'll work it out. I just haven't hit the need for scp functionality _yet_. Also, I'm curious: What platform are you using? I'm trying to provide packaged binaries for "popular" platforms, so if you ran setup.py, I missed yours! mwa -- Mark W. Alexander sl...@do... The contents of this message authored by Mark W. Alexander are released under the Creative Commons Attribution-NonCommercial license. Copyright of quoted materials, if any, are retained by the original author(s). http://creativecommons.org/licenses/by-nc/2.0/ |