2

I'm having an issue setting up git in my Windows computer. I've spun up a VM of CentOS 7 to use as a host-your-own GIT server. Whenever I try and connect to it from by Windows box I have issues, I'm running msysgit as the client on Windows. If I SSH into the CentOS server, and do the same commands using git@localhost, it works perfectly fine. If I use another computer, a linux machine and do the steps shown in the picture, it works fine as well. If I SSH from the msysgit to git@192.168.100.18 it works. It only occurs on my Windows box. I've tried reinstalling the msysgit software. Any idea what could be causing this error?

fatal: protocol error: bad line length character: git@

Thanks!

Issue having in console example

Joshua
  • 293
  • 4
  • 19
  • Did you port-forward your port 22 between your VM and Windows? (http://stackoverflow.com/a/37771161/6309) – VonC Jul 14 '16 at 06:09
  • yes, sorry forgot to mention that when I do ssh git@192.168.100.18 it works perfectly fine and I get access – Joshua Jul 14 '16 at 06:10
  • Can you run `ssh git@192.168.100.18 git-receive-pack hello-world.git` and post its output? – Leon Jul 14 '16 at 06:12
  • From your Windows CMD (and not msys bash), can you set HOME first? `set HOME=%USERPROFILE%`, then try your ssh command. – VonC Jul 14 '16 at 06:12
  • Check if this answer may explain your problem: http://stackoverflow.com/a/14548451/6394138 – Leon Jul 14 '16 at 06:14
  • @Leon It returns: 008a7dc7db90e308a1270572e036b38a6a2d22c61a98 refs/heads/master report-status delete-refs side-band-64k quiet ofs-delta agent=git/1.8.3.1 0000 – Joshua Jul 14 '16 at 06:15
  • what does `git remote -v` show? – Krzysztof Krasoń Jul 14 '16 at 06:16
  • @Leon - It does not solve it, I've been googling this problem for four hours now and tried the .bashrc much earlier. The VM for CentOS server is brand new. – Joshua Jul 14 '16 at 06:16
  • @krzyk git remote shows: origin git@192.168.100.18:hello-world.git (fetch) origin git@192.168.100.18:hello-world.git (push) – Joshua Jul 14 '16 at 06:16
  • @VonC No luck with that, I ran the command, same issue as before when running ssh command – Joshua Jul 14 '16 at 06:17
  • Are you running git 1.8.3? Can you check if the issue persists with git 2.9.0? – VonC Jul 14 '16 at 06:19
  • @VonC server is brand new, set it up today. Windows client I installed Git on it today. What would I be upgrading git to 2.9, which do you think may be outdated? – Joshua Jul 14 '16 at 06:21
  • OK, may be the message you mentioned before was about the git on the server side – VonC Jul 14 '16 at 06:23
  • @VonC yum says "Package git-1.8.3.1-6.el7_2.1.x86_64 already installed and latest version". Should I be installing from somewhere else? – Joshua Jul 14 '16 at 06:26
  • Try making git verbose as described here: http://askubuntu.com/questions/336907/really-verbose-way-to-test-git-connection-over-ssh and see if it will help you to identify the problem. – Leon Jul 14 '16 at 06:37
  • Yes, you can upgrade with a custom ppa. 1.8 is ancient. – VonC Jul 14 '16 at 06:42
  • @VonC I'll take a look around online and see what I can dreg up about installing the latest. – Joshua Jul 14 '16 at 06:45
  • My previous link mostly focused on SSH related problem. [This one](http://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems) explains how to debug git itself. – Leon Jul 14 '16 at 06:46
  • Does `GIT_TRACE=1 git pull origin master` suggest what's going wrong? – Leon Jul 14 '16 at 06:48
  • @Leon I added those, gave more information but nothing useful: http://pastebin.com/0zwUhn0Z – Joshua Jul 14 '16 at 06:49
  • something like http://stackoverflow.com/a/24847953/6309 – VonC Jul 14 '16 at 06:52
  • Good reads: http://stackoverflow.com/q/28700988/6309, http://stackoverflow.com/q/22314298/6309 – VonC Jul 14 '16 at 06:55
  • So did you configure your msysgit to use Putty instead of OpenSSH? – Leon Jul 14 '16 at 06:59
  • If so can you repeat a previous experiment like this: `"$GIT_SSH" git@192.168.100.18 git-receive-pack hello-world.git`? – Leon Jul 14 '16 at 07:05
  • Thanks everyone for helping me out, I learnt a lot! I tried restarting my computer as a 'ha, that'd be funny'. And it's totally working now. Thanks again! – Joshua Jul 14 '16 at 23:39
  • Possible duplicate of [Git Remote: Error: fatal: protocol error: bad line length character: Unab](http://stackoverflow.com/questions/8170436/git-remote-error-fatal-protocol-error-bad-line-length-character-unab) – Edward Thomson Jul 15 '16 at 02:22

3 Answers3

1

I ran into this issue too. After I tried my remote in console

ssh git@gitlab.comlinks.cz

I found out that I forgot to start ssh agent and so the server responded with

git@gitlab.comlinks.cz's password:

waiting for password. Authentication didn't finish yet and so git server is not on the other side but login process is there. So test your connection first.

-1

Try adding a remote using (with protocol specified):

git remote add origin ssh://git@192.168.100.18:hello-world.git 
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
  • No luck. I ran git remote rm origin, then your command, then ran 'git pull origin master', I got back "fatal: No path specified. See 'man git-pull' for valid url syntax" – Joshua Jul 14 '16 at 06:20
-1

This should do the job (note / instead of :):

git remote add origin ssh://git@192.168.100.18/hello-world.git

If not, try to add it manually to your .git/config

Jakuje
  • 24,773
  • 12
  • 69
  • 75