Command git ls-remote times out on Bitbucket, git clone works

bitbucket, capistrano, git, ssh

Solution

As explained here, what I had to do was to add my private key to the authentication agent. First of all, start the authentication agent:

$ eval `ssh-agent -s`

To list the available keys:

$ ssh-add -l
The agent has no identities.

To add a new key:

$ ssh-add ~/.ssh/identity

Where `identity` is the private key file, for example `id_rsa`. From now on, the `git ls-remote` command started working correctly.

Problem

I'm trying to setup an automated deploy configuration with Capistrano, but I keep getting failures when Capistrano tries to run the command ``` git ls-remote -h git@bitbucket.org:vendor/repo.git ``` The SSH key for that user is correctly set up inside Bitbucket, since I can do `git clone git@bitbucket.org:vendor/repo.git` without problems with that user inside that server. I also tested the command `ls-remote` outside the staging server, in my normal development machine where I daily work with Git, and I found that it doesn't work on Bitbucket as well (the SSH keys in my development machine are obviously set up and working). The actual output is: ``` git ls-remote -h ssh://git@bitbucket.org/vendor/repo.git ssh: connect to host bitbucket.org port 22: Operation timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` While I can do `push`'s and `pull`'s without any problem on those same directories. What's up with the `ls-remote` command on Bitbucket? Should I make some additional configuration in addition to the regular one to make it work?

Original source