# -*- coding: utf-8 -*- import paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect( "82.157.112.245", username="ubuntu", password="Xiao4669805", timeout=60, allow_agent=False, look_for_keys=False, ) cmd = r""" set -e sudo nginx -T 2>/dev/null | grep -n 'server_name nomadro.cn' | head # dump the nomadro.cn server block roughly sudo nginx -T 2>/dev/null | awk '/server_name nomadro.cn/{flag=1} flag{print} /server_name / && !/nomadro.cn/{if(flag&&seen++){exit}}' | head -120 echo '==== conf files ====' sudo ls /www/server/panel/vhost/nginx 2>/dev/null | head sudo ls /www/server/nginx/conf/vhost 2>/dev/null | head ls /etc/nginx/sites-enabled 2>/dev/null find /www /etc/nginx -name '*nomadro*' 2>/dev/null | head -40 """ _, o, _ = c.exec_command(cmd, timeout=60, get_pty=True) print(o.read().decode("utf-8", "replace")) c.close()