Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. enter code here
  2.  
  3. #!/usr/bin/python
  4.  
  5. import paramiko
  6. import sys
  7. import time
  8. import Tkinter
  9. import time, os, threading
  10. from Tkinter import *
  11. a=Tkinter.Tk()
  12.  
  13.  
  14.  
  15. #A function that logins and execute commands
  16. def fn():
  17. HOST=raw_input('Enter HOST IP: ')
  18.  
  19. USER=raw_input('Enter USER NAME: ')
  20.  
  21. PASS=raw_input('Enter PASSWORD: ')
  22.  
  23. client1=paramiko.SSHClient()
  24. client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  25. client1.connect(HOST,username=USER,password=PASS)
  26. print "SSH connection to %s established" %HOST
  27. com="cat /etc/motd"
  28. print "Welcome to Account",
  29. com1=raw_input("Enter the command:")
  30. com2=raw_input("Enter if you you want to run multiple command:")
  31. #Gather commands and read the output from stdout
  32. stdin, stdout, stderr = client1.exec_command(com)
  33. print stdout.read()
  34. stdin, stdout, stderr = client1.exec_command( com1)
  35. print stdout.read()
  36. stdin, stdout, stderr = client1.exec_command( com2 )
  37. print stdout.read()
  38. client1.close()
  39. top = os.system("sudo su -")
  40. s = str(top)
  41. print "Logged out of device %s" %HOST
  42.  
  43.  
  44.  
  45. b = Button(a, text='Welcome to the Login World', command=fn)
  46. b.pack()
  47. b.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement