daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest May 16th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. import paramiko
  4. import os
  5.  
  6. hostname = "student.agh.edu.pl"
  7. port = 22
  8. username = "mpadula"
  9. password = "ce9dibo:x:"
  10. paaaas=raw_input('Enter password:')
  11.  
  12. local_path = 'xdd.txt'
  13. remote_path = 'python/test/xdd.txt'
  14.  
  15. client = paramiko.SSHClient()
  16. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  17. try:
  18.     client.connect(hostname, port, username, paaaas)
  19. except paramiko.SSHException as ex:
  20.     paramiko.util.log_to_file("filename.log")
  21.     sys.exit("Podales zle haslo!!!")
  22.  
  23. sftp = client.open_sftp()
  24. sftp.put(local_path,remote_path)
  25. stdin, stdout, stderr = client.exec_command("ls -a")
  26. for line in stdout:
  27.     print(line)
  28.  
  29. sftp.close()
  30. client.close()
RAW Paste Data
Top