paramiko模块的使用

import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname="8.140.144.184",port=22,username="root",password="GENGzeshi123.")

打开一个channel并执行命令

stdin,stdout,stderr = client.exec_command('cd /etc')
stdin,stdout,stderr = client.exec_command('ls /etc')

print(stdout.read().decode('utf-8'))
client.close()

详情:https://www.cnblogs.com/xiao-apple36/p/9144092.html#_label1

posted @ 2021-10-19 15:09  甜甜太阳雨  阅读(29)  评论(0编辑  收藏  举报