Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: Only 1 ssh-agent is needed

Andras Bacsai71ce2eb0a7d0
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index 79b22bce00..bd94e060cd 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -482,7 +482,10 @@ export async function createRemoteEngineConfiguration(id: string) {
const { sshKey: { privateKey }, remoteIpAddress, remotePort, remoteUser } = await prisma.destinationDocker.findFirst({ where: { id }, include: { sshKey: true } })
await fs.writeFile(sshKeyFile, decrypt(privateKey) + '\n', { encoding: 'utf8', mode: 400 })
// Needed for remote docker compose
- await asyncExecShell(`eval $(ssh-agent -s) && ssh-add -q ${sshKeyFile}`)
+ const { stdout: numberOfSSHAgentsRunning } = await asyncExecShell(`ps ax | grep [s]sh-agent | wc -l`)
+ if (numberOfSSHAgentsRunning !== '' && Number(numberOfSSHAgentsRunning.trim()) == 0) {
+ await asyncExecShell(`eval $(ssh-agent -s) && ssh-add -q ${sshKeyFile}`)
+ }
const config = sshConfig.parse('')
const found = config.find({ Host: remoteIpAddress })
if (!found) {