In the course of trying to accomplish a more complicated task (involving hardware security keys and GPG keys for SSH authentication), I have run into an ornery ssh-add
utility on my Windows 10 machine. Quite simply, my ssh-add
fails to connect to the agent, while all other ssh functions work fine.
When I run ssh-add -L
on Powershell 7.0.3, I get the following output:
Error connecting to agent: No such file or directory
However, my ssh-agent
service seems to be running just fine:
C:\Users\[me]> get-service ssh-agent
Status Name DisplayName
------ ---- -----------
Running ssh-agent OpenSSH Authentication Agent
C:\Users\[me]> get-service ssh-agent | select *
UserName : LocalSystem
Description : Agent to hold private keys used for public key authentication.
DelayedAutoStart : False
BinaryPathName : C:\WINDOWS\System32\OpenSSH\ssh-agent.exe
StartupType : Automatic
Name : ssh-agent
RequiredServices : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : True
DisplayName : OpenSSH Authentication Agent
DependentServices : {}
MachineName : .
ServiceName : ssh-agent
ServicesDependedOn : {}
StartType : Automatic
ServiceHandle :
Status : Running
ServiceType : Win32OwnProcess
Site :
Container :
C:\Users\[me]> get-command ssh-add
CommandType Name Version Source
----------- ---- ------- ------
Application ssh-add.exe 7.7.2.1 C:\WINDOWS\System32\OpenSSH\ssh-add.exe
Furthermore, I have my standard public/private SSH keypair in the default location (C:\Users\[me]\.ssh\id_rsa
, C:\Users\[me]\.ssh\id_rsa.pub
). I've used this key extensively on GitHub, and ssh
itself still works fine in Powershell:
C:\Users\[me]> ssh -T [email protected]
Enter passphrase for key 'C:\Users\[me]/.ssh/id_rsa':
Hi [me]! You've successfully authenticated, but GitHub does not provide shell access.
So, given every other aspect of OpenSSH seems to be working fine, why would ssh-add
be misbehaving?
Things I have tried to repair it:
- Removing other SSH utilities from my PATH (e.g. those added by Git installation).
- Disabling/re-enabling the Windows optional feature "SSH Client" (and its "SSH Server" counterpart, which I don't think I need).
- Installing a more recent version of OpenSSH via Chocolatey (https://chocolatey.org/packages/openssh), and pointing all commands to that installation via PATH modification.
- Backing up and removing my
.ssh
folder, generating a new key (viassh-keygen
), and starting from scratch. - Changing the startup type of the
ssh-agent
service between automatic, manual, and disabled
None of the aforementioned activities seemed to have any effect whatsoever. All other ssh
tools worked fine (assuming the optional feature was enabled, and service was running), but ssh-add
did not.
What other recommendations do others have for diagnosing this ornery utility?