Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add keys to ssh-agent, communication with agent failed #1234

Closed
draftsteve opened this issue Aug 16, 2018 · 26 comments
Closed

Can't add keys to ssh-agent, communication with agent failed #1234

draftsteve opened this issue Aug 16, 2018 · 26 comments

Comments

@draftsteve
Copy link

"OpenSSH for Windows" version

(Get-Item (Get-Command ssh).Source).VersionInfo.FileVersion
7.6.0.0

Installed in c:\Windows\System32\OpenSSH in the 1803 Windows update.

Client OperatingSystem
Windows 10 Pro 1803

What is failing
ssh-add can't add keys to the ssh-agent.

Expected output
The keys are accepted and listed when ssh-add -l is run.

Actual output

ssh-add ..ssh\secret.pem
Could not add identity "..ssh\secret.pem": communication with agent failed

ssh-add -l
error fetching identities: communication with agent failed

output from ssh-agent.log:
4688 2018-08-16 15:19:37.613 error: LookupAccountNameW on SSHD account failed with 1789
4688 2018-08-16 15:19:37.615 fatal: failed to retrieve client details
13372 2018-08-16 15:32:40.157 error: LookupAccountNameW on SSHD account failed with 1789
13372 2018-08-16 15:32:40.157 fatal: failed to retrieve client details
972 2018-08-16 15:42:25.752 error: LookupAccountNameW on SSHD account failed with 1789
972 2018-08-16 15:42:25.752 fatal: failed to retrieve client details
9088 2018-08-16 15:47:46.669 error: LookupAccountNameW on SSHD account failed with 1789
9088 2018-08-16 15:47:46.672 fatal: failed to retrieve client details

There doesn't seem to be an sshd.exe in C:\Windows\System32\OpenSSH. I think I'm just missing a setting somewhere because I've gotten this working on other Windows machines of the same version with no issue.

@manojampalam
Copy link
Contributor

see if this helps: #1133

@draftsteve
Copy link
Author

I read through this issue.

I am using posh-git so I tried deleting the environment variables SSH_AGENT_PID and SSH_AUTH_SOCK but they don't exist. I'm guessing I'm using a newer version of posh-git?

Not loading posh-git doesn't seem to help either and the ssh-agent service starts fine.

@manojampalam
Copy link
Contributor

That check in ssh-agent can be removed as sshd now runs as SYSTEM. We'll fix it.

As a workaround to unblock you, could you create/install a dummy sshd service like this:
sc.exe create sshd binPath=C:\Windows\System32\OpenSSH\ssh.exe

@draftsteve
Copy link
Author

I created the dummy sshd service as described.

ssh-add now works as expected. Thank you @manojampalam! This was driving me crazy.

manojampalam added a commit to PowerShell/openssh-portable that referenced this issue Jan 5, 2019
PowerShell/Win32-OpenSSH#1263
Issue: ssh-agent is using default sign algorithm, without considering related flags in request
Fix: parse flags and consider sign algorithm input

PowerShell/Win32-OpenSSH#1234
Issue: ssh-agent has old logic to lookup sshd account
Fix: remove this redundant logic
@ajrock
Copy link

ajrock commented Oct 3, 2019

That check in ssh-agent can be removed as sshd now runs as SYSTEM. We'll fix it.

As a workaround to unblock you, could you create/install a dummy sshd service like this:
sc.exe create sshd binPath=C:\Windows\System32\OpenSSH\ssh.exe

Sorry to reanimate a dead thread, but just wanted to chime in that this solution works even for this failure in Oct 2019, thank you very much!

@LukeCarrier
Copy link

LukeCarrier commented Feb 24, 2020

@manojampalam are you able to give an indication as to when this might ship? This ticket is closed but the need to create a dummy sshd service is still present even in Insiders builds.

ssh-agent was disabled, and even after enabling refused to work until I created the dummy sshd service, on upgrade to 19569.1000.

@ISkomorokh
Copy link

The workaround is still relevant in July 2020!

@bagajjal
Copy link
Collaborator

@ISkomorokh - The fix be part of next windows release which is available in fall timeframe this year.

@lbotinelly
Copy link

The workaround is still relevant in July 2020!
...do you mean September 2020?

@SomethingWithPhp
Copy link

workaround still relevant... winver 20H2

@LukeCarrier
Copy link

I think this saga will finally be closed by #1693. Good job Microsoft, it only took two years 🎉

@ittayd
Copy link

ittayd commented Nov 3, 2020

@LukeCarrier , I installed openssh via chocolatery, but still have this error. Why do you think it is solved by that release?

@thomassuckow
Copy link

You can also just install the OpenSSH server windows feature to mitigate this issue even if you never start the openssh server service.

@rbreaves
Copy link

rbreaves commented Nov 24, 2020

Still relevant sadly and yes the workaround above does work, cs.exe wrapper. Feels like this should have been a pretty high priority awhile ago, but at least there's indication that the fix is coming.

@moaxcp
Copy link

moaxcp commented Jan 13, 2021

Just ran into this and the workaround fixed it. Thanks!

@cconrad
Copy link

cconrad commented Feb 5, 2021

Still a good workaround in February 2021. Thank you

@valentinovamsi
Copy link

worked like a charm, thank you :)

@ferdinandosimonetti
Copy link

ferdinandosimonetti commented Feb 15, 2021

Windows 10 20H2 build 19042.746.
Last friday my SSH Agent worked like a charm.
Today, I had to install OpenSSH Server to get rid of the
error fetching identities: communication with agent failed

@dsisnero
Copy link

Still needed workaround

@yangruan
Copy link

yangruan commented Mar 3, 2021

That check in ssh-agent can be removed as sshd now runs as SYSTEM. We'll fix it.

As a workaround to unblock you, could you create/install a dummy sshd service like this:
sc.exe create sshd binPath=C:\Windows\System32\OpenSSH\ssh.exe

I had to run powershell as administrator to run this, but then I could ssh-add in any other powershell terminal.

@wcarson
Copy link

wcarson commented Mar 3, 2021

March 2021...workaround still needed and still works

@cima
Copy link

cima commented Mar 17, 2021

ssh-add used to work until last week, this week it needs the workaround. This issue needs to be reopened.

@LeszekKalibrate
Copy link

winver 20H2
Applied fix and Github is working now, but getting error in BASH cmd now:

$ git pull
CreateProcessW failed error:193
ssh_askpass: posix_spawn: Unknown error
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

@jbanks9
Copy link

jbanks9 commented Nov 8, 2021

That check in ssh-agent can be removed as sshd now runs as SYSTEM. We'll fix it.

As a workaround to unblock you, could you create/install a dummy sshd service like this: sc.exe create sshd binPath=C:\Windows\System32\OpenSSH\ssh.exe

HAY I know this is old, hope you are still around. When I tried using the work around with my local user path I got the error:

[SC] OpenSCManager FAILED 5: Access is denied.

Do you know how I am able to fix this error?

@Spaxe
Copy link

Spaxe commented Nov 25, 2021

Hi @jbanks9 you need to run PowerShell with Administrator privileges. It worked for me just now.

@SlinkySlonkyOlivia
Copy link

Sorry to revive this thread; but the workaround unfortunately did not work for me, despite running in admin priv...
It only told me the service already exists, and ssh-add -l still no worky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests