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()