Guest User

Untitled

a guest
May 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import paramiko
  2. from glob import glob
  3. import posixpath
  4.  
  5. def xfer_callback(cur, total):
  6. print("{}...{}".format(cur, total))
  7.  
  8. ssh_client =paramiko.SSHClient()
  9. ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  10. ssh_client.connect(hostname="localhost",username="td",
  11. password="notmyrealpassword")
  12. ftp = ssh_client.open_sftp()
  13.  
  14.  
  15. remote_base = "/home/td/tmp/deleteme"
  16.  
  17. files = glob("*.py")
  18. count = 1
  19. for fn in files:
  20. print("sending {} of {}".format(count, len(files)))
  21. ftp.put(fn, posixpath.join(remote_base, fn), xfer_callback)
  22. count += 1
  23.  
  24. $ python3 test.py
  25. sending 1 of 6
  26. 411...411
  27. sending 2 of 6
  28. 557...557
  29. sending 3 of 6
  30. 453...453
  31. sending 4 of 6
  32. 1117...1117
  33. sending 5 of 6
  34. 32768...118000
  35. 65536...118000
  36. 98304...118000
  37. 118000...118000
  38. sending 6 of 6
  39. 515...515
Add Comment
Please, Sign In to add comment