Search code examples
gitcapistranobitbucket

Capistrano fails authenticate with git


While trying to deploy a website using capistrano, I get the following message:

  INFO ---------------------------------------------------------------------------
  INFO START 2016-10-19 21:56:37 +0200 cap staging deploy
  INFO ---------------------------------------------------------------------------
  INFO [95790a6d] Running /usr/bin/env mkdir -p /tmp as [email protected]
 DEBUG [95790a6d] Command: /usr/bin/env mkdir -p /tmp
  INFO [95790a6d] Finished in 0.407 seconds with exit status 0 (successful).
 DEBUG Uploading /tmp/git-ssh-mysite-staging-username.sh 0.0%
  INFO Uploading /tmp/git-ssh-mysite-staging-username.sh 100.0%
  INFO [0cd82d0b] Running /usr/bin/env chmod 700 /tmp/git-ssh-mysite-staging-username.sh as [email protected]
 DEBUG [0cd82d0b] Command: /usr/bin/env chmod 700 /tmp/git-ssh-mysite-staging-username.sh
  INFO [0cd82d0b] Finished in 0.029 seconds with exit status 0 (successful).
  INFO [0265a2c7] Running /usr/bin/env git ls-remote --heads [email protected]:username/mysite.git as [email protected]
 DEBUG [0265a2c7] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-mysite-staging-username.sh" ; /usr/bin/env git ls-remote --heads [email protected]:username/mysite.git )
 DEBUG [0265a2c7]       conq: repository access denied.
 DEBUG [0265a2c7]       fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

However when I run this command manually, as the same user, everything works fine:

$ export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-mysite-staging-username.sh" ; /usr/bin/env git ls-remote --heads [email protected]:username/mysite.git
928c1e393778f25869f14958151c4ea1dc7d68b6    refs/heads/master

I've verified that my public key is bitbucket deployment keys for the repository. This worked fine before. Is there any way I can debug this further?


Solution

  • I found the solution here. Apparently ssh-agent needs to be running.