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