Managing SSH Keys in Windows

Paul Kelly
1 min readSep 3, 2024

--

This article accompanies a short video on this subject which you can find at my Modern Curiosity Shop channel on Youtube. Here I’ve summarised the commands shown in the video just in case they went by too quick, or you wanted to be able to copy and paste them.

All these commands assume that you are using the default location for SSH keys which is: $USER_HOME/.ssh (Linux, MacOS) or $env:USERPROFILE (Windows).

Generating the keypair:
keygen

Adding the SSH Identity on Linux and MacOS

Enter a passphrase of at least 20 characters when prompted.

Start the ssh-agent on Unix like systems (Linux, MacOS):

eval `ssh-agent` 

Add the private key to the agent:

ssh-add

Enter the passphrase when prompted.

Adding the SSH Identity on Windows

Open an Administrator Powershell terminal, then enable and start the ssh agent service:

Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent

Then set the GIT_SSH environment variable to the location of ssh.exe for your user profile:

[Environment]::SetEnvironmentVariable("GIT_SSH", "$((Get-Command ssh).source)", [System.environmentVariableTarget]::User)

Now you should be able to run ssh-add from any new Powershell or command terminal.

--

--

Paul Kelly
Paul Kelly

Written by Paul Kelly

http://www.youtube.com/@moderncuriousityshop Solutions Architect, consultant, and software developer.

No responses yet