Guest User

Untitled

a guest
Dec 11th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. import datetime, time
  2. from time import sleep
  3. from Tkinter import *
  4. import paramiko
  5. def backup():
  6. canvas = Canvas(page3, relief = FLAT, background = "#D2D2D2", width = 694, height = 120)
  7. canvas.pack()
  8. txtOutput = Text(canvas, wrap = NONE, height =14, width = 86, borderwidth=2)
  9. txtOutput.pack()
  10. def backup():
  11.  
  12. try:
  13. ssh = paramiko.SSHClient()
  14. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  15. ssh.connect("t0001cms01", port=22, username='cms', password='sl33py')
  16. transport = ssh.get_transport()
  17. session = transport.open_session()
  18. session.get_pty()
  19.  
  20. except paramiko.AuthenticationException:
  21. print("Authentication failed, please verify your credentials: %s")
  22. except paramiko.SSHException as sshException:
  23. print("Unable to establish SSH connection: %s" % sshException)
  24. except paramiko.BadHostKeyException as badHostKeyException:
  25. print("Unable to verify server's host key: %s" % badHostKeyException)
  26. except Exception as e:
  27. print(e.args)
  28.  
  29.  
  30. stdin, stdout, stderr =session.exec_command("su")
  31.  
  32. stdin.write("password" + 'n')
  33. stdin.flush()
  34.  
  35. command1 = 'menu'
  36. command2= '5'
  37. command3='6'
  38.  
  39. stdin, stdout, stderr =session.exec_command(command1)
  40.  
  41. stdin, stdout, stderr =session.exec_command(command2)
  42.  
  43. stdin, stdout, stderr =session.exec_command(command3)
Add Comment
Please, Sign In to add comment