paramiko连接服务器

import paramiko

def connect_to_server():
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    print('------------开始连接服务器-----------')
    client.connect('xxx.xxx.x.xxx', 22, username='root', password='password', timeout=5)
    print('------------认证成功!.....-----------')

    stdin, stdout, stderr = client.exec_command('cmd')

connect_to_server()
posted @ 2020-11-03 23:17  疯狂列表推导式  阅读(72)  评论(0编辑  收藏  举报