Signing Git Commits with SSH Key doesn't work with SSH Agent on Windows #4726
-
I am trying to use Signing Git Commits with SSH Key git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey "ssh-ed25519 <public key id>" All works fine on WSL, but not on Windows > git commit --allow-empty --message="Testing SSH from Win"
error: Couldn't get agent socket?
fatal: failed to write commit object OpenSSH client works with SSH Agent on Windows and on WSL. All keys are present in the agent SSH_AUTH_SOCK=$HOME/.ssh/wsl-ssh-agent.sock
if [ ! -S "$SSH_AUTH_SOCK" ]
then
export SSH_AUTH_SOCK
/usr/bin/socat UNIX-LISTEN:"$SSH_AUTH_SOCK",fork EXEC:"$(which npiperelay.exe) -ei -s //./pipe/openssh-ssh-agent",nofork 2>&1 &
fi But I don't understand what I have to tweak for Git Bash while git can use SSH Agent to pull my commits from private repo |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The problem might be a mismatch between the native Windows ("PowerShell") variant of OpenSSH and the variant bundled with Git for Windows ("MSYS"). The bug reporting template contains a suggestion to paste the contents of You can find out which OpenSSH variant Git for Windows is using by calling |
Beta Was this translation helpful? Give feedback.
-
Yeah, it shows OpenSSH MINGW64 ~
$ grep SSH /etc/install-options.txt
SSH Option: OpenSSH Full /etc/install-options.txt under the spoiler$ cat /etc/install-options.txt Editor Option: VIM Custom Editor Path: Default Branch Option: Path Option: Cmd SSH Option: OpenSSH Tortoise Option: false CURL Option: OpenSSL CRLF Option: CRLFCommitAsIs Bash Terminal Option: MinTTY Git Pull Behavior Option: Merge Use Credential Manager: Enabled Performance Tweaks FSCache: Enabled Enable Symlinks: Disabled Enable Pseudo Console Support: Disabled Enable FSMonitor: Disabled and next option doesn't help
So, how can I change it? |
Beta Was this translation helpful? Give feedback.
-
Maybe do you have several github accounts? |
Beta Was this translation helpful? Give feedback.
I understand your point, sorry for misunderstanding your use case. In that case, try the following:
You will need to let Git know where the SSH_AUTH_SOCK is. On Windows, this should be a named pipe that you can connect to, but Git Bash is a POSIX environment and the SSH client expects a UNIX domain socket.
You can use npiperelay to create a link between the UNIX domain socket that Git Bash / Mingw64 can understand, and the named pipe that ssh-pageant (or any Pageant compatible agent) provides.
Here are the basics steps:
Download npiperelay (or compile it using go get github.com/jstarks/npiperelay)
Create a script named
start_agent
in~/bin/
or/usr/bin/
: