56 lines
1.4 KiB
JavaScript
56 lines
1.4 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', async () => {
|
|
console.log('SSH连接成功');
|
|
|
|
try {
|
|
console.log('\n=== 检查80和443端口 ===');
|
|
await executeCommand('netstat -tlnp | grep -E ":80|:443"');
|
|
|
|
console.log('\n=== 测试HTTP访问 ===');
|
|
await executeCommand('curl -s http://hs.yifenbao.cn/h5/ | head -5');
|
|
|
|
console.log('\n=== 测试HTTPS访问 ===');
|
|
await executeCommand('curl -s -k https://hs.yifenbao.cn/h5/ | head -5');
|
|
|
|
console.log('\n=== 检查hs.yifenbao.cn配置是否有SSL ===');
|
|
await executeCommand('cat /www/server/panel/vhost/nginx/hs.yifenbao.cn.conf');
|
|
|
|
} catch (error) {
|
|
console.error('检查失败:', error.message);
|
|
} finally {
|
|
conn.end();
|
|
}
|
|
});
|
|
|
|
function executeCommand(cmd) {
|
|
return new Promise((resolve) => {
|
|
conn.exec(cmd, (err, stream) => {
|
|
if (err) {
|
|
console.error('命令执行错误:', err.message);
|
|
resolve();
|
|
return;
|
|
}
|
|
|
|
stream.stdout.on('data', (data) => process.stdout.write(data));
|
|
stream.stderr.on('data', (data) => process.stdout.write(data));
|
|
|
|
stream.on('close', () => resolve());
|
|
});
|
|
});
|
|
}
|
|
|
|
conn.on('error', (err) => {
|
|
console.error('SSH连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect(config); |