Using Git via SSH on Windows 10 (1803) on Powershell
Recently did a fresh install of Windows 10 with all the vital updates and tried to use git fetch
on both cmd
and powershell
but was prompted to enter my ssh key so I tried to run ssh-add
but I got an error saying Error connecting to agent: No such file or directory
so then I tried ssh-agent
and got an error saying unable to start ssh-agent service, error :1058
so what could it be?
A quick scan of Get-Service ssh-agent | select *
showed the following
UserName : LocalSystem
Description : Agent to hold private keys used for public key authentication.
DelayedAutoStart : False
BinaryPathName : C:\Windows\System32\OpenSSH\ssh-agent.exe
StartupType : Disabled
Name : ssh-agent
RequiredServices : {}
CanPauseAndContinue : False
CanShutdown : False
CanStop : False
DisplayName : OpenSSH Authentication Agent
DependentServices : {}
MachineName : .
ServiceName : ssh-agent
ServicesDependedOn : {}
StartType : Disabled
ServiceHandle : Microsoft.Win32.SafeHandles.SafeServiceHandle
Status : Stopped
ServiceType : Win32OwnProcess
Site :
Container :
I quickly noticed that the StartType
was set to Disabled
. Not sure for what reason? To fix this I had to first change it back to Manual
then start the service again.
Get-Service -Name ssh-agent | Set-Service -StartupType Manual
Start-Service ssh-agent
But it didn't end here, I also had to instruct git to look for ssh in Windows' directory
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
So now that git knows where to look for ssh we can now add our private key to the ssh authentiction agent ssh-add
then double checking with ssh-add -l
2048 SHA256:p80/dPfeSzXZPM7ba61214oXCNzMB+v+s/K8gexampleaWzx7Y /home/owo/.ssh/id_rsa (RSA)