0

I use python paramiko operate a network firewall. when I login to the firewall with terminal,It look like this: when I login to the firewall with terminal

But when I use python's paramiko code below,It returns is not my expected. when I hit configure command, it should in "config" mode, but it is not worked. Any suggestions for me. TKS use python paramiko

def send_cmd(cmd, ch):
    cmd += '\r'
    result = ''
    while True:
        time.sleep(0.2)
        ret = ch.recv(65535)
        ret = ret.decode('utf-8')
        result += ret
        break
    return result

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("11.1.1.122", "22", "root", "xxxx", timeout=15)
ch = ssh.invoke_shell()
a = send_cmd('configure', ch)
a = send_cmd('address 1.1.0.1-123123', ch)
print(a)
ssh.close()
Hu YunTao
  • 1
  • 1

0 Answers0