git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Yangyang Hua <hyy_41@live.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: When using several ssh key, Git match ssh key by host, instead of hostname in ssh config file.
Date: Thu, 26 Jan 2023 14:46:54 +0000	[thread overview]
Message-ID: <OSYP286MB0215D880FA9D82B74E393DD691CF9@OSYP286MB0215.JPNP286.PROD.OUTLOOK.COM> (raw)

Hi, 
I find when I use several ssh keys with the right config file and clone my private repo, git can't match the key by hostname.
I try ssh-add command to add the keys. "ssh -T git@github.com" can work, but git clone/push/pull these action display "Permission denied (publickey)".
Test in git version 2.38.1.windows.1 with win10 and git version 2.34.1 with Ubuntu 22.04.1 LTS
I check the -v and -vvv log, git does read my config file in ~/.ssh.

After I change the repo address to host("github") in my ssh config file, i can clone the repo and push/pull.
Host github
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_111
So I change the host to "github.com" in ssh config, everything is back to normal.
Host github.com
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa_111

 I think when git read ssh config, it uses host to match the key instead of hostname. Is this bug?

             reply	other threads:[~2023-01-26 14:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 14:46 Yangyang Hua [this message]
2023-01-26 15:56 ` When using several ssh key, Git match ssh key by host, instead of hostname in ssh config file Junio C Hamano
2023-01-27  1:57   ` Yangyang Hua

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OSYP286MB0215D880FA9D82B74E393DD691CF9@OSYP286MB0215.JPNP286.PROD.OUTLOOK.COM \
    --to=hyy_41@live.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).