Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enter code here
- #!/usr/bin/python
- import paramiko
- import sys
- import time
- import Tkinter
- import time, os, threading
- from Tkinter import *
- a=Tkinter.Tk()
- #A function that logins and execute commands
- def fn():
- HOST=raw_input('Enter HOST IP: ')
- USER=raw_input('Enter USER NAME: ')
- PASS=raw_input('Enter PASSWORD: ')
- client1=paramiko.SSHClient()
- client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client1.connect(HOST,username=USER,password=PASS)
- print "SSH connection to %s established" %HOST
- com="cat /etc/motd"
- print "Welcome to Account",
- com1=raw_input("Enter the command:")
- com2=raw_input("Enter if you you want to run multiple command:")
- #Gather commands and read the output from stdout
- stdin, stdout, stderr = client1.exec_command(com)
- print stdout.read()
- stdin, stdout, stderr = client1.exec_command( com1)
- print stdout.read()
- stdin, stdout, stderr = client1.exec_command( com2 )
- print stdout.read()
- client1.close()
- top = os.system("sudo su -")
- s = str(top)
- print "Logged out of device %s" %HOST
- b = Button(a, text='Welcome to the Login World', command=fn)
- b.pack()
- b.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement