I found the solution to this problem in the following thread and will paraphrase it here.
Git with SSH on Windows
Git does not by default use the same SSH path as the SSH command. Therefore, verifying connection with SSH to Gitlab (or GitHub) is not guaranteed to work with cloning repositories via SSH. It needs to be added to the system environment. This is not the case on Linux since git and ssh are pre-installed. You'll need to specify the path variable for Git.
Start a command prompt window (don't use Power Shell) and use the following commands.
where ssh
This should return the location of the SSH program. My system returned the following.
C:\Windows\System32\OpenSSH\ssh.exe
Check the path that Git is using for SSH by using the command
set GIT_SSH
This will return either an empty path or the current path selected. If it differs from the one previously found, then you must set the path.
This next part will be a test run and then it will be made into a permanent solution once confirmed.
In the same command prompt window use the same set command but this time assign it the path found.
set GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe
or
set GIT_SSH=[YOUR PATH TO SSH]
Check that with this modification you can clone using SSH. If this works then we now take steps to make the correction permanent in all terminal command prompts and power shell.
Follow the next steps for Windows10 (might differ for Windows11)
- Use the search bar to find Edit the System Environment Variable
- Select Advance
- Select Environment Variables...
- Decide if the change should be at system level or user level and find the GIT_SSH variable. If none exists, then create it with new.
- Assign variable name as GIT_SSH and variable value as the value path found previously.
- Select OK to confirm all changes and then apply when back at System Environment Variables
Confirm this change has taken effect by closing the command prompt window or starting a new command prompt or power shell and trying again to clone the command. If the clone command works, then then it's fixed.
Enjoy!!