#!/usr/bin/env python3 import paramiko import sys sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) _i, o, e = c.exec_command( "nc -vz -w 3 82.157.112.245 62300 2>&1; nc -vz -w 3 82.157.112.245 52300 2>&1", timeout=20, ) print((o.read() + e.read()).decode("utf-8", "replace")) c.close()