#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Kahn
import paramiko
def main():
print("hello world")
# 建立远程连接
transport = paramiko.Transport(('172.16.37.21', 22))
transport.connect(username='root', password='pwd123')
# 实例化SSH对象
ssh = paramiko.SSHClient()
ssh._transport = transport
# 执行远程命令
cmd = 'hostname;date;'
stdin, stdout, stderr = ssh.exec_command(cmd)
print(stdout.read().decode())
if __name__ == '__main__':
main()