import { Client } from 'ssh2'; const conn = new Client(); conn.on('ready', () => { console.log('=== 检查Nginx配置 ==='); conn.exec('docker exec huishou cat /etc/nginx/conf.d/default.conf', (err, stream) => { if (err) { console.log('ERR:', err); conn.end(); return; } let config = ''; stream.on('data', (d) => config += d.toString()); stream.on('close', () => { console.log('Nginx配置:', config); conn.end(); }); }); }); conn.on('error', (err) => { console.log('连接错误:', err.message); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });