cmder icon indicating copy to clipboard operation
cmder copied to clipboard

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

Open dom-devel opened this issue 8 years ago • 15 comments

Purpose of the issue

  • [x] 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.

dom-devel avatar May 23 '18 11:05 dom-devel

Same issue here after the latest Windows update :/ (with ConEmu version 161206)

lneveu avatar May 23 '18 11:05 lneveu

Same issue, with latest version (180506)

raulfragoso avatar May 23 '18 19:05 raulfragoso

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

Stanzilla avatar May 24 '18 08:05 Stanzilla

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

lneveu avatar May 24 '18 08:05 lneveu

Thanks @Stanzilla ! Works for me.

raulfragoso avatar May 24 '18 14:05 raulfragoso

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

dom-devel avatar May 25 '18 10:05 dom-devel

@Stanzilla Thanks, that's worked for me.

SiqiLu avatar Jun 02 '18 11:06 SiqiLu

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.

johncrim avatar Oct 31 '18 22:10 johncrim

We need to support older versions of Windows as well

Stanzilla avatar Oct 31 '18 22:10 Stanzilla

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.

scottfalkingham avatar Nov 13 '18 23:11 scottfalkingham

If you are using default ssh client, you can switch git to use it too (answer was found here): git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

EnverOsmanov avatar Feb 19 '19 14:02 EnverOsmanov

@Stanzilla maybe you could use feature detection to set up default ssh for Windows version that support it or let that be the default and downgrade for non-native ssh?

tomsseisums avatar Mar 13 '19 13:03 tomsseisums

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

This seems like a much better solution than removing native OpenSSH from Windows path, which could have lots of consequences

upugo-dev avatar Apr 17 '19 16:04 upugo-dev

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

squaricdot avatar Jun 26 '19 13:06 squaricdot

Windows does that.

Stanzilla avatar Jun 26 '19 18:06 Stanzilla