Created
November 7, 2017 00:12
-
-
Save vortexau/f601363d5fafceadacbd7777779abaf7 to your computer and use it in GitHub Desktop.
Xamarin Mac Host SSH Connection
This file contains 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
#!/usr/bin/env python | |
import paramiko | |
import base64 | |
# Run in /mnt/c/Users/<username>/AppData/Local/Xamarin/MonoTouch | |
# Unfortunately this does NOT work yet, as I do not understand the passphrase.key | |
# file contents entirely (it appears to be bytes inside the base64 encoded string) | |
# and how to use it as the SSH key. | |
with open("passphrase.key", 'r') as file: | |
passphrase = base64.b64decode(file.read()) | |
k = paramiko.RSAKey.from_private_key_file("id_rsa", password=passphrase) | |
c = paramiko.SSHClient() | |
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
print "connecting" | |
c.connect( hostname = "<target>", username = "<username>", pkey = k ) | |
print "connected" | |
commands = [ "uname -a", "whoami" ] | |
for command in commands: | |
print "Executing {}".format( command ) | |
stdin , stdout, stderr = c.exec_command(command) | |
print stdout.read() | |
print( "Errors") | |
print stderr.read() | |
c.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment