Fix Git Deploy Key "Permission Denied (publickey)" on Coolify
Error: git@github.com: Permission denied (publickey) / Failed to read Git source
Coolify can't clone your Git repository because the SSH deploy key it's offering isn't the one your Git host is expecting, so the deploy fails before the build even starts.
Older Coolify versions wrote every SSH deploy key to the same shared path on the host (/root/.ssh/id_rsa), so a stray leftover id_rsa.pub, or two deployments racing for the same key file, can leave SSH offering the wrong key — or no key — to the Git host. Secondary servers also don't automatically inherit the key attached to your primary server, so a deploy that clones fine on one server can fail on another until you explicitly attach the key there too. Coolify's PR #10440 fixes the root cause by writing a per-deployment key file with IdentitiesOnly=yes so SSH can no longer offer the wrong key, but older releases still hit this.
The fix
SSH into the Coolify host and check /root/.ssh/ for a stray id_rsa.pub left over from an old key — remove it and retry the deploy.
rm /root/.ssh/id_rsa.pubConfirm the exact public key Coolify shows under Keys & Tokens is added as a Deploy Key on the repo (read-only access is enough unless the app needs to push).
If you're deploying to a secondary server, explicitly attach the same private key to that server's entry in Coolify — it is not inherited automatically from the primary server.
Update to a Coolify version that includes PR #10440 if you're on an older release; it writes a per-deployment key file with IdentitiesOnly=yes so SSH can't offer the wrong key.
If it still fails, regenerate the key pair in Coolify and add the new public key to the Git host, replacing the old one.
Verify it worked
From the Coolify host, authenticate with the exact deploy key Coolify is using — a successful auth message means the key is correct, and a redeploy should clone without error.
ssh -T git@github.com -i <deploy-key-path>Related Coolify errors
- www.domain.com cert error but apex works
- Build-time error: process.env.NEXT_PUBLIC_* / VITE_* / API URL is undefined during build — values set in Coolify are empty in the built bundle (e.g. ReferenceError or fetch to "undefined")
- WebSocket connection to 'wss://<your-domain>:6001/app/...' failed (UI shows "WARNING: Cannot connect to real-time service")
- Coolify auto deploy not working / GitHub webhook shows no deliveries after a push
Sources
- github.com/coollabsio/coolify/issues/3743
- github.com/coollabsio/coolify/issues/7724
- github.com/coollabsio/coolify/issues/6959
- github.com/coollabsio/coolify/issues/3517
- github.com/coollabsio/coolify/issues/7964
- github.com/coollabsio/coolify/pull/10440
- coolify.io/docs/applications/ci-cd/github/deploy-key