Skip to content

Instantly share code, notes, and snippets.

@vortexau
Created November 7, 2017 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vortexau/f601363d5fafceadacbd7777779abaf7 to your computer and use it in GitHub Desktop.
Save vortexau/f601363d5fafceadacbd7777779abaf7 to your computer and use it in GitHub Desktop.
Xamarin Mac Host SSH Connection
#!/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