Skip to content

Instantly share code, notes, and snippets.

@getadeo
Forked from batok/paramiko_example.py
Last active August 29, 2015 14:21
Show Gist options
  • Save getadeo/9687645185812c1c5b14 to your computer and use it in GitHub Desktop.
Save getadeo/9687645185812c1c5b14 to your computer and use it in GitHub Desktop.
import paramiko
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting"
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k )
print "connected"
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ]
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