Guest User

Untitled

a guest
Nov 21st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. # !/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import paramiko
  5. import os
  6. import subprocess
  7. import json
  8.  
  9.  
  10. def connect(filename):
  11. with open(filename) as configure:
  12. js = json.load(configure)
  13. client = paramiko.SSHClient()
  14. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  15. client.connect(hostname=js['host'], username=js['username'],
  16. password=js['password'][0], port=js['port'][0])
  17. stdin, stdout, stderr = client.exec_command('ls -l')
  18. data = stdout.read() + stderr.read()
  19. client.close()
  20. print (data)
  21.  
  22.  
  23. connect('config.json')
Add Comment
Please, Sign In to add comment