1. asyncssh.connect()参数
参数:known_hosts=None,解决asyncssh host key is not trusted,解决输入yes问题
# 连接华为设备,执行命令
async def run_process():
ip_addr = "28.104.87.140"
user = "root"
password = "123456"
kex_algs = ["diffie-hellman-group1-sha1", "diffie-hellman-group-exchange-sha1"]
async with asyncssh.connect(ip_addr, username=user, password=password, kex_algs=kex_algs, encryption_algs=['aes256-cbc'], mac_algs=['hmac-sha2-256'], known_hosts=None) as conn:
async with conn.create_process(stderr=asyncssh.STDOUT) as process:
res = [1,2,3,4,5,6]
content = {"res": res}
return content