Created
September 29, 2018 06:52
-
-
Save tthtlc/52b459dad851caf55aa593b842f4916b to your computer and use it in GitHub Desktop.
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 | |
ssh = paramiko.SSHClient() | |
key = paramiko.RSAKey.from_private_key_file("id_rsa.pem") | |
###openssl rsa -in /path/to/encrypted/key -out /paht/to/decrypted/key | |
### remember to decrypt as it is encrypted by default (output as id_rsa.pem) | |
#key = paramiko.DSSKey.from_private_key_file(keyfilename) | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
ssh.connect("172.17.0.2", username="root", pkey=key) | |
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("ls -axptr") | |
output=ssh_stdout.readlines() | |
print '\n'.join(output) | |
ssh.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment