gwrichard
gwrichard

Reputation: 95

fatal: protocol error: bad line length character: Unab

I have a Windows 2008 R2 Server Standard Edition. I have FreeSSHd installed along with Git. Windows firewall has exceptions set to port 22. I have the SSH server setup to accept only SSH public keys. I can login to the server fine using terminal (i.e. ssh gregory@hostname). When I go to use the git clone command (e.g. git clone ssh://gregory@hostname/path_to_my_repo) I get this error:

fatal: protocol error: bad line length character: Unab

I am at an absolute loss as to what's causing it. I have Shell, SFTP and Tunnel protocols enabled.

Upvotes: 8

Views: 8825

Answers (3)

akunak
akunak

Reputation: 1

In my case, I had an

echo $HOSTNAME

in my .bashrc and .bash_profile that I was using to diagnose some connection problems. This gave me the message:

fatal: protocol error: bad line length character: [VSR 

when I tried to git pull from an ssh repo. Removing the echo statements makes things work; the '[VSR' is just the first 4 characters from the echo.

Upvotes: 0

NeyMello
NeyMello

Reputation: 1

I had the same problem today at my job... so I found this: Setting up a Git Server on Windows Server 2008 R2

What you need to see is below:

Making Git work on the server:

  1. If not already done, install msysgit on your server (I would recommend to install it directly to C:\Git or at least a path that has no spaces because I had some weird issues with “spaced” paths)

  2. Add C:\Git\bin to the PATH variable. This is very important!! sh.exe and other dependencies are in this folder

  3. Now go to C:\Git\bin and add the following two files

gup.sh grp.sh 4. Open gup.sh in your favorite editor and insert

C:/Git/libexec/git-core/git-upload-pack.exe $* 5. Open grp.sh and insert

C:/Git/libexec/git-core/git-receive-pack.exe $* The $* essentially rips off the single quotes from the repository path argument, so a path that has spaces in it won’t work here either I guess

Basically we’re done now and all git operations from the client should work. For a clone you have to type

git clone -u 'sh gup.sh' ssh://username@server/path/to/myrepo.git or a push would be

git push --exec 'sh grp.sh' ssh://username@server/path/to/myrepo.git but that is not very elegant.

Cleaning things up:

  1. At first we want to get rid of the whole repo path by specifying a remote alias

git remote add origin ssh://username@server/path/to/myrepo.git Where “origin” would be the alias name

  1. Next we set the config for the git-upload-pack and git-receive-pack so we don’t have to reference the shell script all the time.

git config remote.origin.uploadpack 'sh gup.sh' and

git config remote.origin.receivepack 'sh grp.sh' That’s it. Now we can use the normal git commands without any additional parameters:

git clone origin git push origin master git pull origin ...

Upvotes: 0

Related Questions