fix: runSsh 改用 base64 管道传脚本,彻底避免 bash -c 嵌套导致的输出卡住问题

This commit is contained in:
liufumingren 2026-07-25 01:59:29 +08:00
parent b99995de24
commit b4ad9c53c6

View File

@ -220,10 +220,12 @@ function buildSshBaseArgs(config) {
}
function runSsh(config, remoteScript, options = {}) {
// Base64 编码脚本传给远端 bash,避免 shell 嵌套引用和输出信号问题
const encoded = Buffer.from(remoteScript, 'utf8').toString('base64');
const args = [
...buildSshBaseArgs(config),
`${config.username}@${config.host}`,
`bash -c ${quoteForBash(remoteScript)}`,
`echo ${quoteForBash(encoded)} | base64 -d | bash`,
];
return runCommand('ssh', args, {