48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const config = {
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
};
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('SSH连接成功');
|
|
|
|
conn.exec('docker exec huishou grep -o "inputMode[^,]*" /usr/share/nginx/html/h5/assets/pages-weigh-*.js', (err, stream) => {
|
|
if (err) {
|
|
console.error('搜索失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let output = '';
|
|
stream.stdout.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('inputMode相关代码:');
|
|
console.log(output);
|
|
|
|
conn.exec('docker exec huishou grep -o "manual" /usr/share/nginx/html/h5/assets/pages-weigh-*.js', (err, stream) => {
|
|
let manualOutput = '';
|
|
stream.stdout.on('data', data => manualOutput += data);
|
|
stream.on('close', () => {
|
|
console.log('\nmanual出现位置:');
|
|
console.log(manualOutput);
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.error('SSH连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect(config); |