import getpass from pathlib import Path import paramiko client = paramiko.SSHClient() client.load_host_keys(str(Path.home() / ".ssh" / "known_hosts")) client.connect("47.108.78.12", username="root", password=getpass.getpass("SSH password: "), timeout=20) try: commands = [ "systemctl is-active fdm-studio; ss -ltnp '( sport = :9999 )'", "grep -R -n -E 'listen|server_name' /etc/nginx/conf.d /etc/nginx/sites-enabled 2>/dev/null", 'curl -sS -I --resolve cdis.cn:443:127.0.0.1 https://cdis.cn; curl -sS -I http://cdis.cn', 'openssl x509 -in /etc/letsencrypt/live/cdis.cn/fullchain.pem -noout -issuer -subject -dates', 'tail -n 8 /var/log/nginx/fdm-cdis-access.log; tail -n 8 /var/log/nginx/fdm-cdis-error.log', ] for command in commands: print(command, flush=True) _, out, err = client.exec_command(command, timeout=30) print(out.read().decode() + err.read().decode(), flush=True) finally: client.close()