48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 查看当前配置 ===\n');
|
|
|
|
conn.exec('cat /www/server/panel/vhost/nginx/hs.yifenbao.cn.conf', (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 -la /www/server/nginx/conf/vhost/', (err, stream2) => {
|
|
if (err) {
|
|
console.log('查看目录失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream2.on('data', (data) => {
|
|
console.log('\n虚拟主机目录:', data.toString());
|
|
});
|
|
|
|
stream2.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |