cmder: Can no longer use ssh-add: Error connecting to agent

Purpose of the issue

  • Bug report (encountered problems/errors)
  • Feature request (request for new functionality)
  • Question

Description of the issue

Can no longer add ssh keys using ssh-add. Instead I’m thrown the following error:

Error connecting to agent: No such file or directory

I believe this has started happening since the latest Windows update.

My set-up I’m currently booting an ssh-agent at startup, having un-commented before:

call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"

I’m running:

  • Windows 10
  • Latest preview/alpha image

Further debugging I took a look at the environment variables set:

SSH_AUTH_SOCK & SSH_AGENT_PID

Both are set:

  • SSH_AUTH_SOCK: /tmp/ssh-yzpgZ44bVaMU/agent.17940
  • SSH_AGENT_PID: 4304

Which correctly creates into:

C:\Users\Dominic\AppData\Local\Temp\ssh-yzpgZ44bVaMU\agent.17940

I tried setting, SSH_AUTH_SOCK to the full windows path above, however at this point I then get:

Could not add identity ".ssh\id_rsa": invalid format

Apologies if this is an issue with ConEmu, I’m not knowledgeable enough to be able to separate the two cleanly.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

try which ssh-agent Windows 1803 comes with their own OpenSSH version by default now, you probably want to remove that from PATH

Another option (possibly better than using another copy of openssh) is to use the Windows ssh agent. Check status in powershell:

get-service ssh*

If the service is disabled, start it and set to manual:

Set-Service -Name ssh-agent -StartupType Manual
Start-Service ssh-agent

If there’s a reason to use a git version of openssh instead of the windows-installed version, that would be good to know.

Thanks @Stanzilla! I removed %SYSTEMROOT%\System32\OpenSSH\ from my PATH and it’s working fine now 😃

Instead of removing %SYSTEMROOT%\System32\OpenSSH\ from your path, merely add the following to your user-profile.cmd file.

set "PATH=%GIT_INSTALL_ROOT%\usr\bin;%PATH%"

It will add git\usr\bin to your path again, but this time it comes before the %SYSTEMROOT%\System32\OpenSSH\ entry, which allows the ssh-agent calls to work again.

Thanks @Stanzilla ! Works for me.

Thanks @Stanzilla! I removed %SYSTEMROOT%\System32\OpenSSH\ from my PATH and it’s working fine now 😃

where did you remove it??? how did it got added in the first place?? by cmder?? why do that if it’s wrong?? why do i need to spend 3 hours to get ssh-agent working with this software??

why do i need to google to many different github issues or PR or whatever to get any insight to enable this. as you might notice i’m going quite mental on this, at least it’s a terrible and experience full of anger

@Stanzilla Thanks, that’s worked for me.

Yep that’s worked for me as well. Cheers @Stanzilla!