Last active
March 10, 2017 12:53
-
-
Save diegopacheco/7ec08050a19609eb76dfd941fe428166 to your computer and use it in GitHub Desktop.
Boto3 + Paramiko script to connect to a Box
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
import paramiko | |
k = paramiko.RSAKey.from_private_key_file("YOUR_PEM_FILE.pem") | |
c = paramiko.SSHClient() | |
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
c.connect( hostname = "ec2-1-1-1-1.us-west-2.compute.amazonaws.com", username = "ec2-user", pkey = k ) | |
stdin , stdout, stderr = c.exec_command("hostname") | |
print("stdout: " + stdout.read()) | |
print("stderr" + stderr.read()) | |
c.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment