const { Client } = require('ssh2'); const conn = new Client(); conn.on('ready', () => { console.log('=== 检查容器内h5目录内容 ==='); conn.exec('docker exec huishou ls -la /usr/share/nginx/html/h5/', (err, stream) => { if (err) { console.log('ERR:', err); conn.end(); return; } stream.on('data', (d) => console.log(d.toString())); stream.on('close', () => { console.log('\n=== 检查容器内h5/index.html ==='); conn.exec('docker exec huishou cat /usr/share/nginx/html/h5/index.html', (err2, stream2) => { if (err2) { console.log('ERR2:', err2); conn.end(); return; } stream2.on('data', (d) => console.log(d.toString())); stream2.on('close', () => conn.end()); }); }); }); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });