439

When I try to start the ssh-agent on Windows 10 via PowerShell (with elevated right or without) by entering Start-Service ssh-agent I get the error

unable to start ssh-agent service, error :1058

When I check of the service is running via Get-Service ssh-agent is returns that the service is stopped.

How can I get the ssh-agent running?

quervernetzt
  • 10,311
  • 6
  • 32
  • 51

6 Answers6

697

Yeah, as others have suggested, this error seems to mean that ssh-agent is installed but its service (on windows) hasn't been started.

You can check this by running in Windows PowerShell:

> Get-Service ssh-agent

And then check the output of status is not running.

Status   Name               DisplayName
------   ----               -----------
Stopped  ssh-agent          OpenSSH Authentication Agent

Then check that the service has been disabled by running

> Get-Service ssh-agent | Select StartType

StartType
---------
Disabled

I suggest setting the service to start manually. This means that as soon as you run ssh-agent, it'll start the service. You can do this through the Services GUI or you can run the command in admin mode:

 > Get-Service -Name ssh-agent | Set-Service -StartupType Manual

Alternatively, you can set it through the GUI if you prefer.

services.msc showing the properties of the OpenSSH Agent

Medeni Baykal
  • 4,223
  • 1
  • 28
  • 36
Donal
  • 8,430
  • 3
  • 16
  • 21
  • 15
    I was receiving the error `Set-Service: Service 'OpenSSH Authentication Agent (ssh-agent)' cannot be configured due to the following error: Access is denied.`. There were no problems doing it via the GUI though. – Akshay Gaur May 27 '20 at 13:22
  • 19
    I assume that means you weren't using an admin shell – Donal Jul 03 '20 at 12:57
  • 4
    Yes I wasn't using an admin shell. – Akshay Gaur Jul 06 '20 at 17:02
  • 4
    After Windows 10 update 2004 this was reset to `disabled` and had to repeat these instructions. – Cwista Aug 31 '20 at 06:51
  • I was getting "Access is denied" when trying to do "-StartType Manual" (probably due to it's a working laptop I don't know) but the GUI does the job. Thanks for sharing the extra tip! – uniquegino Dec 26 '20 at 00:38
  • 6
    for those wondering how to access the GUI, just: bring up the start menu --> type Services --> find the OpenSSH Authentication Agent service – onofricamila Jan 21 '21 at 19:18
  • It helped me. Did not know what is the problem, but it was because of the StartType disabled. Thanks! – ekar Feb 23 '21 at 17:48
  • `'Get-Service' is not recognized as an internal or external command, operable program or batch file.` Got this error in powershell – Ahmed Nawaz Khan Dec 13 '21 at 07:28
  • @AhmedNawazKhan what's your powershell version? In powershell, type: ```$PSVersionTable``` – Donal Dec 13 '21 at 19:28
  • This is the answer and should be marked as such. – J Weezy Feb 08 '22 at 20:03
208

I solved the problem by changing the StartupType of the ssh-agent to Manual via Set-Service ssh-agent -StartupType Manual.

Then I was able to start the service via Start-Service ssh-agent or just ssh-agent.exe.

quervernetzt
  • 10,311
  • 6
  • 32
  • 51
7

I get the same error in Cygwin. I had to install the openssh package in Cygwin Setup.

(The strange thing was that all ssh-* commands were valid, (bash could execute as program) but the openssh package wasn't installed.)

betontalpfa
  • 3,454
  • 1
  • 33
  • 65
7

To solve this problem follow only a few steps:

1 => open Window Powershell as administrator and write

2 => Get-Service ssh-agent //(you will find status stopped )

3 => Now write in the Powershell

4 => Set-Service ssh-agent -StartupType Manual

you will find status running.. hopefully help to resolve the problem.

sherkhan
  • 811
  • 8
  • 8
5

Adding here that if you have this problem and run start-ssh-agent in PowerShell it will "switch" to cmd(not powershell) like functionality until you exit the batch job started by your previous command. If you don't, you can no longer access PowerShell functions and will get errors like: 'Get-Service' is not recognized as an internal or external command, operable program or batch file

enter image description here

Don Kartacs
  • 396
  • 3
  • 8
3

This just happens to me because I was running the command in a non-administrator Powershell. Running it with admin powers solved the problem

mmerle
  • 451
  • 4
  • 10