git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to use multiple SSH keys on Git exe (not bash)

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jan 10, 2018, 15:58 UTC
Message-ID
<87mv1laeoe.fsf@evledraar.gmail.com>
In-Reply-To
<CALKyTE7VpeCoofzzutdEmsjtGe7NaC3EywQWJvM0EOH3U6XvoA@mail.gmail.com>
On Wed, Jan 10 2018, Sam Millman jotted:
Show 42 quoted lines
> I am trying, for the sake of PhpStorm, to get multiple SSH keys
> working using git . exe, which means no GitBash.
>
> I can get the keys to work just fine with GitBash.
>
> I edited my .ssh/config to look like (I know this is incorrect):
>
> Host bitucket . org
> IdentityFile ~/.ssh/id_rsa1
>
> Host bitbucket . org
> IdentityFile ~/.ssh/id_rsa
>
>
> And id_rsa1 works, I can actually pick from the other repo. But, of
> course, id_rsa does not now.
>
> I change to:
>
> Host bitucket . org-dd
> HostName bitbucket . org
> IdentityFile ~/.ssh/id_rsa1
>
> Host bitbucket . org-sas
> HostName bitbucket . org
> IdentityFile ~/.ssh/id_rsa
>
> And now only id_rsa works.
>
> I also tried combining the two IdentityFile lines together like so
> (for some reason):
>
> Host bitucket . org
> IdentityFile ~/.ssh/id_rsa1
> IdentityFile ~/.ssh/id_rsa
>
> I have even tried running ssh-agent . exe, adding id_rsa1 to that and
> then running the git clone with no result.
>
> The weird thing is, I have two public keys as well and they both load
> in the ssh . exe (they return errors about format), I just cannot get
> my ssh . exe to work with multiple private keys.

This might just be a special case of the problem of some hosting providers picking only the first key you provide, as described in this thread: https://public-inbox.org/git/20180103102840.27897-1-avarab@gmail.com/

If so, you either need to hack around this with ssh host aliases, or a custom GIT_SSH_COMMAND.

Show 45 quoted lines
> On 10 January 2018 at 15:29, Sam Millman <sam.millman@gmail.com> wrote:
>> I am trying, for the sake of PhpStorm, to get multiple SSH keys working
>> using git . exe, which means no GitBash.
>>
>> I can get the keys to work just fine with GitBash.
>>
>> I edited my .ssh/config to look like (I know this is incorrect):
>>
>> Host bitucket . org
>> IdentityFile ~/.ssh/id_rsa1
>>
>> Host bitbucket . org
>> IdentityFile ~/.ssh/id_rsa
>>
>>
>> And id_rsa1 works, I can actually pick from the other repo. But, of course,
>> id_rsa does not now.
>>
>> I change to:
>>
>> Host bitucket . org-dd
>> HostName bitbucket . org
>> IdentityFile ~/.ssh/id_rsa1
>>
>> Host bitbucket . org-sas
>> HostName bitbucket . org
>> IdentityFile ~/.ssh/id_rsa
>>
>> And now only id_rsa works.
>>
>> I also tried combining the two IdentityFile lines together like so (for some
>> reason):
>>
>> Host bitucket . org
>> IdentityFile ~/.ssh/id_rsa1
>> IdentityFile ~/.ssh/id_rsa
>>
>> I have even tried running ssh-agent . exe, adding id_rsa1 to that and then
>> running the git clone with no result.
>>
>> The weird thing is, I have two public keys as well and they both load in the
>> ssh . exe (they return errors about format), I just cannot get my ssh . exe
>> to work with multiple private keys.
>>
>> Has anyone got any ideas on how to solve this?
Previous: Randall S. BeckerNext: Sam Millman
Message 5 of 10 in “Re: How to use multiple SSH keys on Git exe (not bash)”
  1. Sam MillmanJan 10, 2018
  2. Randall S. BeckerJan 10, 2018
  3. Sam MillmanJan 10, 2018
  4. Randall S. BeckerJan 10, 2018
  5. Ævar Arnfjörð BjarmasonJan 10, 2018
  6. Sam MillmanJan 10, 2018
  7. Randall S. BeckerJan 10, 2018
  8. Sam MillmanJan 10, 2018
  9. Randall S. BeckerJan 10, 2018
  10. Sam MillmanJan 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.