const { Client } = require('ssh2'); const conn = new Client(); conn.on('ready', () => { conn.exec('head -50 /www/huishou/dist/build/h5/index.html', (err, stream) => { if (err) { console.log('ERR:', err); } else { stream.on('data', (d) => console.log('index.html头部:', d.toString())); } stream.on('close', () => { conn.exec('ls -la /www/huishou/dist/build/h5/assets/*.js | grep -E "(weigh|index)" | head -20', (err2, stream2) => { if (err2) { console.log('ERR2:', err2); } else { stream2.on('data', (d2) => console.log('JS文件:', d2.toString())); } stream2.on('close', () => conn.end()); }); }); }); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });