Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import threading
  2. import paramiko
  3. import subprocess
  4.  
  5. def ssh_command(ip, user, passwd, command):
  6.     client = paramiko.SSHClient()
  7.     #client.load_host_keys('/home/justin/.ssh/known_hosts')
  8.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  9.     client.connect(ip, username=user, password=passwd)
  10.     ssh_session = client.get_transport().open_session()
  11.     if ssh_session.active:
  12.         ssh_session.exec_command(command)
  13.         print ssh_session.recv(1024)
  14.     return
  15. ssh_command('192.168.1.98', 'justin', 'lovesthepython', 'id')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement