Skip to content

Instantly share code, notes, and snippets.

@klashxx
Created May 31, 2016 10:26
Show Gist options
  • Save klashxx/a665e2277930871489adf953021683ee to your computer and use it in GitHub Desktop.
Save klashxx/a665e2277930871489adf953021683ee to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os
import paramiko
key = paramiko.RSAKey.from_private_key_file(
os.path.expanduser('~/.ssh/id_rsa_priv'))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname='test', pkey = key)
stdin , stdout, stderr = client.exec_command('hostname')
print stdout.read()
print stderr.read()
client.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment