擅长:python、mysql、java
<p>你看了<a href="https://github.com/jbardin/scp.py" rel="nofollow noreferrer">Github page?</a>它们提供了一个如何执行此操作的示例:</p>
<pre><code>from paramiko import SSHClient
from scp import SCPClient
import sys
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('example.com')
# Define progress callback that prints the current percentage completed for the file
def progress(filename, size, sent):
sys.stdout.write("%s\'s progress: %.2f%% \r" % (filename, float(sent)/float(size)*100) )
# SCPCLient takes a paramiko transport and progress callback as its arguments.
scp = SCPClient(ssh.get_transport(), progress = progress)
scp.put('test.txt', '~/test.txt')
# Should now be printing the current progress of your put function.
scp.close()
</code></pre>