Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import paramiko
  2. import os
  3.  
  4. HOST = 'youdomain.com'
  5. PORT = 22
  6. USERNAME = 'username'
  7. PASSWORD = 'password'
  8. REMOTE_PATH = '/remote/sftp/path/'
  9.  
  10.  
  11. with paramiko.Transport((HOST, PORT)) as transport:
  12. transport.connect(username = USERNAME, password = PASSWORD)
  13. with paramiko.SFTPClient.from_transport(transport) as sftp:
  14. fname = 'somefile' # Make sure the file exists
  15. localpath = os.path.abspath(fname)
  16. targetpath = REMOTE_PATH + fname
  17. # Upload local file to remote SFTP
  18. sftp.put(localpath, targetpath)
  19. print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement