I’ve been using Git for Windows with its bundled SSH for a long time. Recently, I decided to re-install Git and configure it to use Windows SSH, and since then running SSH-related commands in the Git environment results in problems. For example, my .bash_profile
script checks if ssh-agent
is running and if not it starts it. I have not modified this code since switching to Windows SSH:
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
When I load Git, I get prompted Enter passphrase for C:Usersme/.ssh/id_ed25519:
, even though Windows ssh-agent is running. I enter my password and I get the message Could not add identity "C:Usersme/.ssh/id_ed25519": invalid format
. If I enter ssh-add -l
I get the message error fetching identities: invalid format
. Meanwhile, if I enter ssh-add -l
in a Windows command prompt, it works fine and shows my key. If I run ssh-add
in Windows, I get prompted to enter my password, after which it successfully re-adds the key. Doing the same in Git results in the same invalid forrmat
error. This is despite the fact I can confirm ssh-add
refers to the same program in both environments. In Git:
which ssh-add
/c/Windows/System32/OpenSSH/ssh-add
In Windows:
where ssh-add
C:WindowsSystem32OpenSSHssh-add.exe