Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/usr/bin/env python
- # -*- coding: utf-8 -*-
- import paramiko
- import os
- import subprocess
- import json
- def connect(filename):
- with open(filename) as configure:
- js = json.load(configure)
- client = paramiko.SSHClient()
- client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(hostname=js['host'], username=js['username'],
- password=js['password'][0], port=js['port'][0])
- stdin, stdout, stderr = client.exec_command('ls -l')
- data = stdout.read() + stderr.read()
- client.close()
- print (data)
- connect('config.json')
Add Comment
Please, Sign In to add comment