|
@@ -14,6 +14,10 @@ const url = process.argv[8]
|
|
|
const [serverIp, port] = serverAddress.split(':');
|
|
|
const sshPort = port || '22'; // 如果没有指定端口,默认使用22
|
|
|
|
|
|
+// 这里填入您之前获取的主机密钥的 SHA256 指纹
|
|
|
+//plink -ssh root@192.168.0.109 -P 22 exit
|
|
|
+const hostKey = "SHA256:qS+DxUoW0NM1Nc//Dh0ebUHTB+MXMNTr+BF0njciwrU"
|
|
|
+
|
|
|
// 检查命令是否可用
|
|
|
function commandExists(command) {
|
|
|
try {
|
|
@@ -44,12 +48,12 @@ function uploadServer() {
|
|
|
const sshCommand = `cd ${filePath} && rm -rf static && unzip -o ${fileName}`;
|
|
|
if (process.platform === 'win32') {
|
|
|
// Windows
|
|
|
- runCommand(`pscp -P ${sshPort} -pw ${password} ./zip/${fileName} ${username}@${serverIp}:${filePath}`);
|
|
|
- runCommand(`plink -P ${sshPort} -ssh ${username}@${serverIp} -pw ${password} -batch "${sshCommand}"`);
|
|
|
+ runCommand(`pscp -P ${sshPort} -pw ${password} -hostkey "${hostKey}" ./zip/${fileName} ${username}@${serverIp}:${filePath}`);
|
|
|
+ runCommand(`plink -P ${sshPort} -ssh ${username}@${serverIp} -pw ${password} -hostkey "${hostKey}" -batch "${sshCommand}"`);
|
|
|
} else {
|
|
|
// Mac/Linux
|
|
|
- runCommand(`sshpass -p "${password}" scp -P ${sshPort} ./zip/${fileName} ${username}@${serverIp}:${filePath}`);
|
|
|
- runCommand(`sshpass -p "${password}" ssh -p ${sshPort} ${username}@${serverIp} "${sshCommand}"`);
|
|
|
+ runCommand(`sshpass -p "${password}" scp -o StrictHostKeyChecking=no -P ${sshPort} ./zip/${fileName} ${username}@${serverIp}:${filePath}`);
|
|
|
+ runCommand(`sshpass -p "${password}" ssh -o StrictHostKeyChecking=no -p ${sshPort} ${username}@${serverIp} "${sshCommand}"`);
|
|
|
}
|
|
|
console.log('编译打包后自动部署到服务器上完成');
|
|
|
console.log(`服务器上的地址:${url}`);
|
|
@@ -61,10 +65,10 @@ function delPublic() {
|
|
|
const sshCommand = `cd ${filePath} && rm -rf plugins`;
|
|
|
if (process.platform === 'win32') {
|
|
|
// Windows
|
|
|
- runCommand(`plink -P ${sshPort} -ssh ${username}@${serverIp} -pw ${password} -batch "${sshCommand}"`);
|
|
|
+ runCommand(`plink -P ${sshPort} -ssh ${username}@${serverIp} -pw ${password} -hostkey "${hostKey}" -batch "${sshCommand}"`);
|
|
|
} else {
|
|
|
// Mac/Linux
|
|
|
- runCommand(`sshpass -p "${password}" ssh -p ${sshPort} ${username}@${serverIp} "${sshCommand}"`);
|
|
|
+ runCommand(`sshpass -p "${password}" ssh -o StrictHostKeyChecking=no -p ${sshPort} ${username}@${serverIp} "${sshCommand}"`);
|
|
|
}
|
|
|
console.log('plugins 等目录移除完成');
|
|
|
}
|
|
@@ -85,7 +89,7 @@ function runCode() {
|
|
|
|
|
|
//判断命令是否支持
|
|
|
if (process.platform === 'win32') {
|
|
|
- if (!commandExists('putty')) {
|
|
|
+ if (!commandExists('pscp') || !commandExists('plink')) {
|
|
|
console.log('putty 未安装,请先安装 putty');
|
|
|
process.exit(1);
|
|
|
return
|