If you’re developing on Windows and you have multiple keys in Pageant, you may have encountered this line from Bitbucket:
conq: repository access denied. deployment key is not associated with the requested repository.
This happens if you have a deployment key for another one of your projects loaded in Pageant. You can either remove the offending key, or follow these steps to make Pageant always use the correct key for this repository.
PuTTY Saved Sessions
Say the command to clone our repository looks like this:
git clone [email protected]:myname/myproject.git
You can create a saved session in PuTTY that will get used instead by naming the saved session the hostname part of the URL.
So for our above example, we would open PuTTY and navigate to
Connection -> SSH -> Auth
and browse for the private key you want this session to use.
Go back to Session
at the top and put in the same thing in host name and session name (bitbucket.org in this example) and then save it.
After doing this, Pageant will always use the private key file if the host name part matches a saved PuTTY session.
But Wait There’s More…
You might be thinking, “What if I have multiple repositories at the same host name that use different keys.” Well, you can alias them.
Take our above example, you can save a copy of the bitbucket.org session with a different name, in this case we’ll use whatever.
git clone git@whatever:myname/myproject.git
This will work exactly the same as before. “whatever” will use bitbucket.org but with whatever key is saved on the “whatever” session.