loading...
Cover image for How to enable OpenSSH Agent to access your github repositories on Windows PowerShell

How to enable OpenSSH Agent to access your github repositories on Windows PowerShell

aka_anoop profile image Anoop AK ・1 min read

If you are someone coming from a Linux/Mac developer environment to Windows, you would be missing your old friends ssh-agent and ssh-add that are commonly used for authentication while using the SSH protocol for Git.

While WSL2 grants you access to a native Linux environment that you are used to, there would be few who prefer to use PowerShell to accomplish some of the tasks. If you are one of them, read on...

For PowerShell users, previously you had to install OpenSSHUtils to get access to ssh-agent. Windows 10 already ships with OpenSSH Authentication Agent, which is disabled by default. Hence, if you execute ssh-agent in PowerShell, you will get the following error.

unable to start ssh-agent service, error :1058

It's just the matter of enabling the service either from PowerShell(as Admin) or from Services.

Enabling SSH Agent using PowerShell

PowerShell should be run as Administrator to be able to execute the below steps

Set-Service -Name ssh-agent -StartupType Automatic
Set-Service -Name ssh-agent -Status Running

Enabling SSH agent from Services

  • Open Services(Start Menu -> Type "Services")
  • Select OpenSSH Authentication Agent Alt Text
  • Set StartupType to Automatic Alt Text

That's it!
You should now be able to execute ssh-keygen, ssh-agent, and ssh-add from PowerShell.

PS C:\Users\anoop> ssh-add
Enter passphrase for C:\Users\anoop/.ssh/id_rsa:
Identity added: C:\Users\anoop/.ssh/id_rsa (anoop@DESKTOP-ABCD123)

Discussion

pic
Editor guide