This morning, I ran into a new issue doing a simple git clone command on Windows 10, from a PowerShell console. It turns out that it was just a mistake on my part (surprise, right?). Let me describe my train of thought to you.
I wanted to clone a repository, so I ran this command.
git clone ssh://github.com/organization/repo
An astute observer might easily identify what’s wrong here. Upon running this command, I received the following error message.
fatal: protocol error: bad line length character: logi
This error message is obtuse and generally unhelpful, but I’ve seen similarly useless messages before. The full error message is being truncated, for some reason.
I started researching the issue on Google, of course. People were making recommendations about reinstalling Git for Windows, configuring git to use ssh.exe instead of plink.exe, and so on.
My gut feeling was that reinstalling anything was unnecessary. After all, git was working just fine recently, right? I continued my search.
Eventually, I found other posts that referenced the git clone command, and I noticed the username in front of the hostname, as in: firstname.lastname@example.org.
It turns out that what I had done was copy the HTTPS URI for the git repository, for example https://github.com/organization/repo, and then simply replaced https with ssh, effectively leaving off the SSH username.
To fix this, all I had to do was add the git@ in front of the hostname.
git clone ssh://email@example.com/organization/repo
It was a simple fix, thankfully. No software reinstallation or complicated SSH client configurations were needed.
Lesson learned: copy the SSH URI from the GitHub web interface, and don’t try to construct it yourself, unless you know what you’re doing. 🙂