Last updated: Apr 4, 2024
Reading time·3 min
The error "unable to start ssh-agent service, error: 1058" occurs when
SSH-Agent is installed on Windows, but the ssh-agent
service has not been
started.
To solve the error, start PowerShell as an administrator and start the service manually using a command or the GUI.
Here is the complete stack trace.
unable to start ssh-agent service, error :1058 Start-Service : Service 'OpenSSH Authentication Agent (ssh-agent)' cannot be started due to the following error: Cannot start service ssh-agent on computer '.'. Access is denied. At line:1 char:1 + Start-service ssh-agent + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException + FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceCommand
First, start PowerShell as an administrator.
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
Get-Service ssh-agent
The Get-Service command will display the status of the OpenSSH Authentication Agent.
The status will most likely be Stopped
as shown in the screenshot.
ssh-agent
service.Get-Service ssh-agent | Select StartType
The start type of the service will most likely be Disabled
as shown in the
screenshot.
If you get the error 'Get-Service' is not recognized as an internal or external command, operable program or batch file, it means that you aren't currently in a PowerShell session.
When you run the start-ssh-agent
command in PowerShell, it switches you to
CMD.
You have to type exit
and press Enter
to exit the CMD session to be able to
issue the Get-Service
command.
exit # Now issue the Get-Service command Get-Service ssh-agent | Select StartType
ssh-agent
service to Manual
by running the
following command.Get-Service -Name ssh-agent | Set-Service -StartupType Manual
When the start type of the ssh-agent
service is set to Manual
, the service
is automatically started when you issue the ssh-agent
command.
Try to issue the Start-Service ssh-agent
command.
Start-Service ssh-agent
You can also use the ssh-agent.exe
command to start ssh-agent
.
ssh-agent.exe
If that didn't work, try setting the start type of the service using the graphic user interface.
ssh-agent
using the GUITo set the start type of the ssh-agent
service to Manual
using the GUI:
Start the Services application.
Scroll down to the OpenSSH Authentication Agent service.
Try to issue the Start-Service ssh-agent
command.
Start-Service ssh-agent
You can also use the ssh-agent.exe
command to start ssh-agent
.
ssh-agent.exe
If that didn't work either, try setting the Startup type to Automatic.
If the error persists, start PowerShell as an administrator:
Click on the Search bar and type PowerShell.
Right-click on the PowerShell application and click "Run as administrator".
ssh-agent
service to Automatic
.Get-Service -Name ssh-agent | Set-Service -StartupType Automatic
Try to issue the Start-Service ssh-agent
command.
Start-Service ssh-agent
You can also use the ssh-agent.exe
command to start ssh-agent
.
ssh-agent.exe
You can learn more about the related topics by checking out the following tutorials: