2009/10/11 Milan Andric <[email protected]>: > Hello, > > Is it possible to use paramiko to transfer a file between two remote > servers? Scp supports this but I could not get it to work with > non-standard ssh ports (not 22). Like: > > scp [email protected]:/over/here/xyz.tgz > [email protected]:/some/dir/ > > This doesn't respect the -P flag for the port. > > So I'm trying to figure out if paramiko can help me transfer a file > between two remote servers without doing the transfer locally first.
Using paramiko you should be able to do it "in-memory" for example using 2 SFTPFiles: http://www.lag.net/paramiko/docs/paramiko.SFTPFile-class.html Something like: remote1 = SSHClient() remote1.load_system_host_keys() remote1.connect('remote1.com') sftp1 = remote1.open_sftp() remote2 = SSHClient() remote2.load_system_host_keys() remote2.connect('remote1.com') sftp2 = remote2.open_sftp() file1 = sftp1.open("/over/here/xyz.tgz",'r') file2 = sftp2.open("/some/dir/xyz.tgz",'w') then do appropriate loop for reading from file1 and writing to file2. remote1.connect('remote1.com') may be replaced with an extra port=<portval> argument. Concerning ssh/scp, may be you ssh to one remote host and launch scp from there? Something like: ssh [email protected]:/some/dir scp [email protected]:/over/here/xyz.tgz . -- Erk Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org _______________________________________________ paramiko mailing list [email protected] http://www.lag.net/cgi-bin/mailman/listinfo/paramiko
