39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 检查服务器配置 ===\n');
|
|
|
|
conn.exec('cat /etc/nginx/conf.d/default.conf 2>/dev/null || cat /etc/nginx/sites-enabled/default 2>/dev/null || cat /etc/nginx/nginx.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.exec('ls -la /www/huishou/', (err, stream2) => {
|
|
if (err) { console.log('ERR:', err); conn.end(); return; }
|
|
let output2 = '';
|
|
stream2.on('data', (d) => output2 += d.toString());
|
|
stream2.on('close', () => {
|
|
console.log('\n/www/huishou/目录:');
|
|
console.log(output2);
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |