Git remote end hung up unexpectedly - windows

I am trying to set up a git repo on my test server when I try to push from my windows computer
git push ssh://git#server.com:/path/.git
I get the error
fatal: The remote end hung up unexpectedly
But when I ssh'd into my server and tried to do the the exact same command it worked just fine. Is this a problem with my git setup or with my windows setup

The problem might be caused by a number of issues:
Git is installed in some weird place on the server, and the environment that "git" user gets when being logged in interactively (you do this by hand via PuTTY or whatever) differs from the environment it gets when being logged in non-interactively (the git client does this for you). This is because Unix shells read different startup files in these cases, and when git uses SSH to spawn remote git instance it still spawns the default (for the user) shell on the server.
You have a local problem (say, you configured Git to use plink.exe to access the server, and it asks you to accept the host's key by entering "y" or "n" (which you can't do).
In any case, try these steps:
Run plink.exe git#server.com "git --version" and see it's able to run Git on the server at all. If you don't use plink.exe use whatever binary is shipped with OpenSSH included with Git for Windows; probably it's ssh.exe.
Export GIT_TRACE=1 before running git push and see if it prints out anything hinting at what went wrong, like this:
C:\foo>GIT_TRACE=1
C:\foo>git push ssh://git#server.com:/path/.git

I suspect the problem is that the user 'git' does not have write access to the remote repository, and that you may be connecting manually with your own username (cemurray, or some such).

Related

Windows, Git and the SSH url/path of a bare repository

I am trying to set up a git repository on our Windows server.
I installed OpenSSH for Windows and Git for Windows.
The OpenSSH server runs on port 2345 to filter out generic bots.
I created a bare and shared repository on C:\git\protocolrepo.git
I couldn't reach it with the URL:
ssh://User#domain#server.com:2345:C:/git/protocol.git
It seems to me to be a malformed URL but everywhere I look on the web I get this, but it just doesn't work.
As I found out in this thread: https://github.com/PowerShell/Win32-OpenSSH/issues/895, the shell might be the cause, so I set the powershell as the default shell of OpenSSH.
This didn't work either and I still needed to use this oddly formed URL.
So I installed Cygwin and set the Cygwin bash as the default shell, and used a more appropriately formed url:
ssh://User#domain#server.com:2345/cygdrive/c/git/protocol.git
I had a little bit more success with this, but it now states the following error message:
fatal: '/cygdrive/c/git/protocol.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
The access rights should be fine as I make use of the same user alltogether, but I'm not 100% sure how this works on Windows.
I'm not sure either how Git/ssh handles this path on Windows.
On a Linux based server this worked just fine with /git/protocol.git path.
Pushing a new branch to a bare repository is something I haven't done in a while either so that also might be done wrong here, but I can't recall it to be an issue.
What would you recommend to debug this issue?
I would start by checking if an interactive SSH session works, before considering using a Git repo SSH URL.
ssh -p 2345 User#domain#server.com
If it does, try and access /C/git/protocol.git in that interactive shell.
If that works, then try for your git commands the URL
ssh://User#domain#server.com:2345/C/git/protocol.git
# or
ssh://User#domain#server.com:2345/c/git/protocol.git

Pushing commits to an SSH-cloned repo via VS Code on WSL returns "Host key verification failed" - it's ok on HTTPS

I'm on a Windows 10 machine and I have both Git Bash and Ubuntu for Windows Subsystem for Linux (WSL) installed. When I use GitHub's official desktop app to clone a repo via HTTPS everything works fine and I can push my commits via Visual Studio Code with no problems whatsoever. I then try to clone a repo via SSH with Hyper (WSL Bash) and get this:
The authenticity of host 'domain.com (a.b.c.d)' can't be established.
RSA key fingerprint is XX:XX:...:XX.
Are you sure you want to continue connecting (yes/no)?
After answering yes and openning that repo in VS Code and try to push my new changes to GitHub, I get this error:
Git: Host key verification failed.
And this is what I get as Git Log in Output:
Host key verification failed.
fatal: Could not read from remote repository.
I have set up my SSH key on WSL using this method and I didn't set up any passphrase. I tried this on my brother's PC which is exactly set up like mine and it worked just fine. I would appreciate any help!
UPDATE: I typed ssh -T git#github.com in Hyper and got this as an answer: You've successfully authenticated, but GitHub does not provide shell access.
P.S. I'm a newbie in programming and stackoverflow, so please be concise and give me step by step instructions. The more you use technical terms, the more I'll probably get lost!
Try first, for that new push, to do it in command line:
cd c:\path\to\local\repo
git status
git log
git remote -v
git push -u origin master
Make sure that:
git status is clean (no pending changes)
git log shows you at least one commit
git remote -v shows you as origin the URL of your remote GitHub repository
(as an SSH URL git#github.com:<you>/<yourRepo>)
Then push, and go back to VSCode.
Should be faster than the other solution:
In vscode open a new terminal of type "Command Prompt"
Run: git push and accept the new key when prompted.
This will store the remote key for future use.

Need help setting up a git server on windows

i'm trying to set up a git server on Windows, but i'm having some issues getting it all to work.
I have locally created a normal repository, and remotely i created a bare repository. On the local repository i added a single text file and committed it, but when I try to push it into the remote repository I always get the following message:
fatal: protocol error: bad line length character: fata
I searched SO and other sources, and most of them suggest it's an issue regarding command echos. I'm using freeSSHd as a SSH solution (remote repository is hosted on a windows server), and I tried to use both the git bash and the windows CMD as a command shell.
I start CMD with /Q to disable echoing and /K to change directory to a directory where repositories are located, so I don't think that would be a problem.
Using the remote desktop, i can clone the repository to a folder next to it, and using the git bash locally i can access the SSH shell and also clone the repository in the same way. But using git clone ssh://<address>:/myRepo.git I always get the above message (The SSH's working folder is the same where the repository is located). Does anyone have any idea what's going on? How can I see what command is triggering the error, and how can I see the full error message?
I also met the same error using freeSSHd as a ssh solution for git server on Windows. I couldn't find a solution for a whole day and gave up. :(
Later I found another powerful ssh server from Bitvise called WinSSHD worked well. It has free version for personal use. I suggest you to switch to it. Though I'd also like to know if there's a fix to the error we both met.
To setup ssh server with WinSSHD is quite simple, and you can add virtual accounts with private/public key access.
The key part is to setup the ssh access for git server. Please follow the steps of the blog here.
It should work well for Windows git client. For Mac, you may meet an error as follows.
grp.sh: No such file or directory
fatal: Could not read from remote repository.
To fix it, you need to create the two files gup.sh and grp.sh in your git bin directory (GIT_PATH/bin or GIT_PATH/libexec/git-core configured in system environment variable PATH) in your git server.
The content of gup.sh:
git-upload-pack.exe $*
The content of grp.sh:
git-receive-pack.exe $*

Git not working with remote server

I have git installed and working as expected on my local system or a network share, but have not been able to get it to access the remote bare repository on my server using ssh.
I have installed msysgit and CopSSH on the server and msysgit, putty and tortoisegit on my local system. I am able to open a putty session or use plink successfully -- at least I believe plink is successful, but more on that in a bit.
When I attempt to clone a remote repository I get this:
D:\Temp> git clone uname#server:e:/path/test.git Test
Cloning into Test...
fatal: protocol error: bad line length character: Micr
The error message has been consistent for a while, but at times (from one reinstall attempt to another) the last four characters will be 'Micr', 'Allo' or something else I don't remember right now. In the currently installed state it is 'Micr'.
So the big question is what am I not doing right?
Although I imagine it would be much easier to correct what was wrong if I could get the actual error message instead of the generic one followed by the first four characters of the actual error message. Any idea if that is possible?
First, you have variables like export GIT_TRACE=1 and export GIT_TRACE_PACKET=1 which can help debugging this kind of situation.
Second, this error is often caused by any kind of display done during the ssh session (see for instance this thread), like a .bashrc on the server side with an echo in it.
I have a wrapper set-up around ssh that sets the window title of the shell to the ssh command argument. That is what messes things up!
See also Git FAQ
Other causes include:
using the right ssh
correctly forcing to use git-shell
using --exec-path from the server_arg on the server side
Note: with Git 2.6+ (Q3 2015), see also "GIT_TRACE_PACKFILE".

Git push command not working with msysgit setup

I installed GIT onto my windows 2k8 server following these directions: http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
All commands work fine except the "push" command. I get this error:
git.exe push -v "origin" master:master
git: '/path/to/repo' is not a git command. See 'git --help'.
Pushing to user#ipaddress/path/to/repo
fatal: The remote end hung up unexpectedly
Does anyone know how to fix this?
It looks like the remote origin is not set up correctly.
I recommend re-creating that remote, either by renaming it or deleting it and making a new one:
git remote rename origin origin_backup
git remote add origin ssh://user:pass#address/path/to/repo.git
Then try again, preferably with a fetch before you push.
What protocol are you using? If git://, then make sure there is a Git daemon listening for connections. If ssh://, make sure you have ssh access and write permission on the appropriate directory tree.
Another possibility is that the server and client are running different versions of Git. It could cause problems if one is running a version that expects commands in the format git cmd and the other expects git-cmd.
First check, if your plain SSH access to 5.16.217.81 is working: is
ssh 5.16.217.81
able to open a connection to the host?
If that is successful, ensure that you specify the path to your repo in a way your SSH server understands. In the HowTo, the path is specified different from the path you typed:
5.16.217.81/d/private/test/ (your path) vs.
<server>:d:/DeeDriveRepos/Repo2
Obviously, the CopSSH server wants colons to separate the drive letter from the host, so that your URL should be 5.16.217.81:d:/private/test/.
If you used Cygwin, your URL would be 5.16.217.81/cygdrive/d/private/test/
My pushes work for msysgit version 1.6.5 but not for 1.7.x

Resources