#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("82.157.112.245", 22, "ubuntu", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False) cmd = r""" echo '=== nginx.conf includes ===' sudo grep -nE 'include|server_name|listen' /www/server/nginx/conf/nginx.conf | head -60 echo '=== find confs ===' sudo find /www/server/nginx -name '*.conf' 2>/dev/null | head -40 sudo find /www/server/panel/vhost -type f 2>/dev/null | head -40 echo '=== www wwwroot ===' ls /www/wwwroot 2>/dev/null | head -30 echo '=== existing certs ===' sudo find /www -path '*cert*' -name 'fullchain.pem' 2>/dev/null | head -20 sudo find /etc/letsencrypt -name 'fullchain.pem' 2>/dev/null | head -10 echo '=== curl local 443 hosts ===' curl -sk -o /dev/null -w '%{http_code} %{ssl_verify_result}\n' --resolve dy.nomadro.cn:443:127.0.0.1 https://dy.nomadro.cn/ || true curl -skI --resolve dy.nomadro.cn:443:127.0.0.1 https://dy.nomadro.cn/ 2>&1 | head -20 echo '=== nginx -T sample servers ===' sudo /www/server/nginx/sbin/nginx -T 2>/dev/null | grep -E 'server_name|listen |# configuration' | head -80 """ _, o, e = c.exec_command(cmd, timeout=90) print((o.read() + e.read()).decode()) c.close()