quervernetzt
quervernetzt

Reputation: 11661

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058"

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?

Upvotes: 504

Views: 483795

Answers (10)

Mark
Mark

Reputation: 1

Because sometimes the system defaults to the service being disabled.

  1. Press "win + R", enter "service.msc", and open the service control panel.
  2. Find the "OpenSSH Authentication Agent" service in it, set it to "Manual", and everything will work fine.

image description

Upvotes: 0

Carson
Carson

Reputation: 8098

You only need to change the StartupType to Manual, and then it will be okay!

Set-Service ssh-agent -StartupType Manual

more example

# Check default value
Get-Service ssh-agent
Get-Service ssh-agent | Select StartType

# Run
Set-Service ssh-agent -StartupType Manual

# Test
ssh-agent


# Stop
Stop-Service ssh-agent
Set-Service ssh-agent -StartupType Disabled

# Test
ssh-agent 

Upvotes: 0

Deepti Kushwaha
Deepti Kushwaha

Reputation: 11

I was facing the same error while adding keys to ssh agent. This is how I got it fixed. I have already generated a new SSH key. Next step is to add ssh key to ssh agent. Open git bash and use this command:

eval $(ssh-agent)

It will show something like this

Agent pid

then simply add path to ssh key

ssh-add path/to/key

for example: ssh-add /c/Users/hp/.ssh/id_ed25519

it may ask for passphrase.

Upvotes: 1

satnhak
satnhak

Reputation: 9861

I was unable to get the SSH agent started due to the executable itself being corrupt. The error I was getting was 1053, won't start in a timely manner.

This was in the event viewer log

Faulting application name: ssh-agent.exe, version: 8.6.0.1, time stamp: 0x624f4fc8
Faulting module name: ssh-agent.exe, version: 8.6.0.1, time stamp: 0x624f4fc8
Exception code: 0xc0000006
Fault offset: 0x0000000000020767
Faulting process id: 0x0x478C
Faulting application start time: 0x0x1DA69733420E80B
Faulting application path: C:\Windows\System32\OpenSSH\ssh-agent.exe
Faulting module path: C:\Windows\System32\OpenSSH\ssh-agent.exe
Report Id: e09f95af-119c-4e70-999b-f49fdaaf76cc

Who knows how this happened, but anyway it did.

To fix this, from an elevated powershell prompt:

Upvotes: 0

Donal
Donal

Reputation: 10130

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

Upvotes: 814

Mohd Sher Khan
Mohd Sher Khan

Reputation: 1127

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.

Upvotes: 11

Don Kartacs
Don Kartacs

Reputation: 426

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

Upvotes: 8

mmerle
mmerle

Reputation: 595

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

Upvotes: 4

betontalpfa
betontalpfa

Reputation: 3752

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.)

Upvotes: 7

quervernetzt
quervernetzt

Reputation: 11661

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.

Upvotes: 234

Related Questions