62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 配置HTTPS ===\n');
|
|
|
|
conn.exec('ls /www/server/panel/vhost/cert/', (err, stream) => {
|
|
if (err) {
|
|
console.log('检查证书失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream.on('data', (data) => {
|
|
console.log('证书文件:', data.toString());
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
conn.exec('ls /www/server/panel/vhost/cert/hs.yifenbao.cn/ 2>/dev/null || echo "证书目录不存在"', (err, stream2) => {
|
|
if (err) {
|
|
console.log('检查证书目录失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream2.on('data', (data) => {
|
|
console.log('\n站点证书:', data.toString());
|
|
});
|
|
|
|
stream2.on('close', () => {
|
|
conn.exec('cat /www/server/nginx/conf/vhost/*.conf 2>/dev/null | head -100', (err, stream3) => {
|
|
if (err) {
|
|
console.log('查看配置失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream3.on('data', (data) => {
|
|
console.log('\n虚拟主机配置:', data.toString());
|
|
});
|
|
|
|
stream3.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |