Git with Pageant and Multiple SSH Keys

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

PuTTY Auth Configuration

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 ( in this example) and then save it.

Session screen of PuTTY

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 session with a different name, in this case we’ll use whatever.

A whatever session in PuTTY

git clone [email protected]whatever:myname/myproject.git

This will work exactly the same as before. “whatever” will use but with whatever key is saved on the “whatever” session.

Leave a Reply

Your email address will not be published. Required fields are marked *