Guest User

pythonsftpdownloader

a guest
Mar 5th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import paramiko
  2. ssh_client = paramiko.SSHClient()
  3. hostname = 'test.rebex.net'
  4. username = 'demo'
  5. password = 'password'
  6. port = '22'
  7. file = 'readme.txt'
  8.  
  9. ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  10. ssh_client.connect(hostname, port, username, password)
  11.  
  12. print('connected to server')
  13. remotepath = '/'
  14. localpath = 'c:/users/ME/documents/file.txt'
  15.  
  16. #download file
  17. ftp_client = ssh_client.open_sftp()
  18. ftp_client.get(remotepath + file, localpath)
  19. ftp_client.close()
  20. print('winning')
Add Comment
Please, Sign In to add comment