Git is ignoring ssh-agent

BorisTheRed

Wise, Aged Ars Veteran
111
Subscriptor++
I have been trying to set up Cmder to use ssh-agent for authentication, and so far it seems that Cmder itself is using it fine, but when I call git, it ignores ssh-agent entirely.

OS: Windows 11 (22H2)
SSH: OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
Cmder, etc.: up to date

I have loaded a couple keys into ssh-agent, and running ssh-add -l returns the expected result, listing the loaded keys.

When I run ssh -v git@github.com, the output includes the expected references to the loaded keys:

Code:
debug1: Will attempt key: ndc\\xxx@yyy RSA SHA256:[redacted] agent
debug1: Will attempt key: ndc\\xxx@yyy RSA SHA256:[redacted] agent

This successfully completes and I get this message at the end:

Code:
Hi borisgred! You've successfully authenticated, but GitHub does not provide shell access.

So, this part is alright. However, if I try to use any git commands, it does not attempt any keys from ssh-agent. I changed ~cmder\vendor\git-for-windows\etc\gitconfig so that sshCommand = ssh -v -A, to see verbose output. I also edited ~cmder\vendor\git-for-windows\etc\ssh\ssh_config adding this section:

Code:
# Github
Host github.com
    HostName github.com
    PreferredAuthentications publickey
    ForwardAgent yes

I also updated ~\.ssh\config with this section:

Code:
# Github
Host github.com
    ForwardAgent yes

Now when I run git clone git@github.com:borisgred/sda.git I get the verbose output. I see these lines appear:

Code:
debug1: Reading configuration data /c/Users/xxx/.ssh/config
debug1: /c/Users/xxx/.ssh/config line 2: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for github.com

It's definitely reading the configuration files. But it's still ignoring ssh-agent.

The verbose output has no references to the keys stored in ssh-agent. So in the end I get git@github.com: Permission denied (publickey). And that's the end.

What am I missing? How do I get git under Cmder to pay attention to ssh-agent?

PS I first posted on Cmder's github page in the discussions section, but that page gets very little fraction, so I'm cross-posting here. I know that's somewhat out of decorum. If either venue gets a resolution, I'll copy that to the other.
 

BorisTheRed

Wise, Aged Ars Veteran
111
Subscriptor++
There might be? Cmder also runs an instance of git-for-windows, which actually handles the git commands. Since normal ssh commands work but git commands don't, I think it's a problem with git-for-windows, somehow.

My current workaround is to add IdentityFile tag to ~\.ssh\config pointing to the right key, and this works for git commands in Cmder. I just have to enter my passphrase every time I run a command that connects to the git server.

It's confusing.