paramiko

时间:2019-06-28 23:25:35   收藏:0   阅读:99
import paramiko
ssh=paramiko.SSHClient()
know_host=paramiko.AutoAddPolicy()
ssh.set_missing_host_key_policy(know_host)
ssh.connect(
    hostname="10.10.21.82",
    port=22,
    username="root",
    password="123"
)
shell=ssh.invoke_shell()
shell.settimeout(1)
command=input(">>>")+"\n"
shell.sent(command)
while True:
    try:
        recv=shell.recv(51.2).decode()
        if recv:
            print(recv)
        else:
            continue
    except:
        command=input(">>>")+"\n"
        shell.sent(command)
ssh.close()

 

原文:https://www.cnblogs.com/wutanghua/p/11105135.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!