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