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

When using several ssh key, Git match ssh key by host, instead of hostname in ssh config file.

From
YHYangyang Hua <hyy_41@live.com>
Date
Jan 26, 2023, 14:46 UTC
Message-ID
<OSYP286MB0215D880FA9D82B74E393DD691CF9@OSYP286MB0215.JPNP286.PROD.OUTLOOK.COM>

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?
Next: Junio C Hamano
Message 1 of 3 in “When using several ssh key, Git match ssh key by host, instead of hostname in ssh config file.”
  1. Yangyang HuaJan 26, 2023
  2. Junio C HamanoJan 26, 2023
  3. Yangyang HuaJan 27, 2023

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.