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

  1. 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.pub
  2. Confirm 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).

  3. 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.

  4. 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.

  5. 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

Sources

Have Emsden Studio fix it for you — from A$149

All Coolify deploy errors