Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- from glob import glob
- import posixpath
- def xfer_callback(cur, total):
- print("{}...{}".format(cur, total))
- ssh_client =paramiko.SSHClient()
- ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh_client.connect(hostname="localhost",username="td",
- password="notmyrealpassword")
- ftp = ssh_client.open_sftp()
- remote_base = "/home/td/tmp/deleteme"
- files = glob("*.py")
- count = 1
- for fn in files:
- print("sending {} of {}".format(count, len(files)))
- ftp.put(fn, posixpath.join(remote_base, fn), xfer_callback)
- count += 1
- $ python3 test.py
- sending 1 of 6
- 411...411
- sending 2 of 6
- 557...557
- sending 3 of 6
- 453...453
- sending 4 of 6
- 1117...1117
- sending 5 of 6
- 32768...118000
- 65536...118000
- 98304...118000
- 118000...118000
- sending 6 of 6
- 515...515
Add Comment
Please, Sign In to add comment