-
-
Save drunkensouljah/6ee87485e3d5e4cd396817e61c502c42 to your computer and use it in GitHub Desktop.
SSHClient.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Very simple SSH client for Pythonista | |
| import paramiko | |
| import console | |
| ssh = paramiko.SSHClient() | |
| ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| host = console.input_alert('Connect to') | |
| user, passwd = console.login_alert('Login') | |
| ssh.connect(host, username=user, password=passwd) | |
| print 'Connected to %s. Type `exit` to disconnect.' % host | |
| while True: | |
| cmd = raw_input() | |
| if cmd == 'exit': | |
| break | |
| stdin, stdout, stderr = ssh.exec_command(cmd) | |
| print stdout.read() | |
| ssh.close() | |
| print 'Disconnected.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment