Revert "🔨 chore: refactor rsync command to securely handle private key passph… (#9)"

This reverts commit b08861e768.
This commit is contained in:
Zitao Xiong
2024-02-22 19:59:05 +08:00
parent 9118728164
commit 5287bb83be

View File

@@ -164,16 +164,8 @@ export function create(params: { name: string; region: string; size: string }) {
throw new Error(`not found: ${loc}`)
}
const hash = generateDirectoryHash(loc).slice(0, 5)
const privateKeyPassword = process.env['PRIVATE_KEY_PASSWORD']
// Use an expect script to interact with ssh-add securely, if privateKeyPassword is set.
let addKeyCommand = privateKeyPassword != null && privateKeyPassword?.length > 0
? `expect -c 'spawn ssh-add ${privateKey}; expect "Enter passphrase for"; send "${privateKeyPassword}\\r"; interact'`
: `ssh-add ${privateKey}`
const rsyncCommand = `eval $(ssh-agent -s) && ${addKeyCommand} && RSYNC_RSH="ssh -i ${privateKey}" rsync -avP ${loc} ${connection.user}@${droplet.ipv4Address}:${remotePath} && kill $SSH_AGENT_PID`
return new local.Command(`${name}:copyFiles ${unroot(loc)}`, {
create: pulumi.interpolate`${rsyncCommand}`,
create: pulumi.interpolate`rsync -avP ${loc} ${connection.user}@${droplet.ipv4Address}:${remotePath}`,
triggers: [hash, loc, remotePath],
})
}