I'm currently trying to access GitHub to clone a repository with SSH.

However, when I enter the url to clone, the server hangs after Initialized empty Git repository in /export/home/nathan/myrepo, as follows:

$ git clone [email protected]:v6/myrepo.git
Initialized empty Git repository in /export/home/nathan/myrepo/.git/

ssh-add -l shows multiple identities.

2048 <fingerprint> /home/vagrant/.ssh/id_rsa (RSA)
2048 <fingerprint> production-infrastructure.pem (RSA)

I have added the public keys for both of the above to my GitHub account.

However, when I attempt ssh -T [email protected], I get something like the following:

Hi otheruser1998! You've successfully authenticated, but GitHub does not provide shell access.

I am not otheruser1998.

I think GitHub may associate the production-infrastructure.pem key with otheruser1998, whose account already has this key.

How do I disable the production-infrastructure.pem key from ssh-agent?

If that doesn't work, can I specify a key for git to use?

As both of these keys are forwarded from my local development machine, I cannot just specify my key file in ~/.ssh/config, as a popular answer to How to tell git which private key to use? recommends.

Neither can I use ssh-add -d production-infrastructure.pem to remove the key, as, again, it requires one to specify the local path to a key file: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/ssh-add.1

The question title seems a little clunky. Please edit. I'll take any help I can get to make it clearer. However, the ultimate goal is to end the situation that makes me run into that silent git clone bug, clone my repository, and move on with life.

  • None of the key files (the one you want to use and the misleading one) aren't avaialble on the machine where you execute the command? If you could make the right key available locally, then I believe superuser.com/a/868699/29509 (ssh-agent option) should help. Mar 31, 2016 at 8:01

1 Answer 1


You could kill ssh-agent, but that would prevent you from reloading production-infrastructure.pem (since you don't seem to have it locally available) after you're done.

As an alternative, you can use the $GIT_SSH environment variable to specify the program that git should use for ssh. You need to create a new shell script with the following two lines:

ssh -i /home/vagrant/.ssh/id_rsa $*

I would save this as ~/bin/githubssh with mode 555. (This is unfortunately necessary because git does not do argument parsing in the GIT_SSH environment variable, it tries to stuff the entire thing into argv[0] when it goes to execute the SSH program.)

Then, when it's time to do the checkout:

$ GIT_SSH=~/bin/githubssh git clone [email protected]:v6/myrepo.git

This will set the GIT_SSH environment variable only for that git command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .