Fixing Git Clone SSH Agent on Windows
Last days I run Git on Windows for a quick upload of something, tried cloning the private repo over SSH, and it bombed out with a permission denied error. Even though a plain SSH test to GitHub worked fine.
As said, normally I work on my Linux Laptop but during Holidays I –had– to build some csharp stuff in windows. So old pains came back :)
fatal: Could not read from remote repository.
Here’s what I saw:
git clone git@github.com:solariz/xxxxxxx.git test
Cloning into 'test'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
But verifying SSH alone:
ssh -T git@github.com
Hi solariz! You've successfully authenticated, but GitHub does not provide shell access.
That checks out, so why the clone failure? If I check ssh-add -L it correctly showed me all of my keys in the agent.
Turns out Git on Windows was using some wrong SSH client by default. Fixed it by pointing Git to the built-in OpenSSH.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
Retried the clone:
git clone git@github.com:solariz/xxxxxxx.git test
Cloning into 'test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
It works now.
git windows commit Editor
While at it, I usually skip vim in Windows shells since I don’t have it installed. Wanted to set Sublime Text as my Git editor instead.
Tried this:
git config --global core.editor "C:/Program Files/Sublime Text/subl.exe -w"
But spaces in the path messed it up. Escaping didn’t help either. Quick fix: Add the Sublime folder to your Windows PATH, then:
git config --global core.editor "subl.exe -w"
Now Git opens Sublime for commits or whatever, no hassle. Small tweaks like these save time when you’re jumping between systems.
Comments
Nothing is loaded from external services until you click.
With a Fediverse or Mastodon account you can reply to this post. Replies from any compatible server are shown below once loaded.
No Mastodon account? You can leave an anonymous comment in the form below; it will appear after moderation.
Mastodon replies
Web mentions
Leave a comment
No account needed. Comments appear after moderation.
You can also reply to this post on Mastodon and your reply will show up here.