Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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()
Add Comment
Please, Sign In to add comment