Git fatal: remote end hung up - windows

So I thought I had finally got everything setup on Windows ... then ran into this issue.
Current setup
URL: ssh://user#host:port/myapp.git
Already run Putty - and can connect using valid .ppk keys through the ~/.ssh/authorized_keys direct. In Git and TortoiseGIT - I set both to use "plink.exe".
Putty works fine - no issues - but when I run that URL into bash I get for a git clone (url)
fatal: the remote end hung up expectedly
In a cygwin bash terminal - running "ssh user#host" - works no probs at all.
Anyone suggest anything?

I found out that using ssh.exe from the Git package works every time, as opposed to the ssh that comes with cygwin (the default).
Using this exported variable seems to help; it's slower (2x or more) but it's more stable. Take it as another workaround.
$ export GIT_SSH=/cygdrive/c/Program\ Files/Git/bin/ssh.exe
FYI:
This version of Msysgit comes with OpenSSH 4.6p1, OpenSSL 0.9.8e. [works]
Cygwin's SSH is OpenSSH 5.5p1, OpenSSL 0.9.8n. [doesn't work]

I had the same problem with plink for git under windows.
On run of plink.exe -v xxx#host.com it started to show
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
login as: <<< trouble
Instead of
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using user "xxx"
To resolve this problem I cleaned up the putty registry records and sessions by
putty.exe -cleanup
After that plink starts afresh and asks to trust and store the host again and it is getting connected with no problem !

Try following steps, maybe something will give you a hint on your problem:
1. Run putty and after setting up server name/user name/keys etc. save those settings.
2. Run plink.exe or plinkw.exe like plink.exe user_name#server, (it'll throw some info at you) just to see if plink can connect to the server.
3. Check again that git knows that it should use plink, I'd say with all VCSs, that's the problem people have most often, apart from their keys not being set up properly.
Normally by now most of your ssh problems would be revealed. Now just fix them. :)
Update:
I think the problem you have is caused by several gits you've got installed. For the msysgit and cygwin git you'd need to set the GIT_SSH variable. That's done via either 'set GIT_SSH=c:\path\putty\plink.exe' or 'export GIT_SSH=/your/path/putty/putty.exe' respectively. If you're also using tortoise git, you'd need to locate 'properties' (or is it settings?) in it's menu, and set the ssh client there.
Apart from all that, when specifying git clone URL, use your login name and the server name in there, e.g. 'git clone ssh://user#server/your/path/repo.git User and server names should be used by plink, and plink should be able to connect to the server with those arguments, when all of those requirements are met, you'll be all set.
Good luck.

If you want to try the cygwin openssh 5.4p1-1, which does seem to work for this, unlike 5.5 or 5.6, you can use the cygwin time machine mirrors. Start setup.exe with -X and add a mirror Url, such as:
ftp://www.fruitbat.org/pub/cygwin/circa/2010/05/20/230133
Be careful not to install too much, i.e. base packages, from an older mirror than the rest of your install.

We had same problem and here is solution how we solved the problem:
at first we got:
zajdan#cyberFuture:~$ git clone ssh://nette#19X.16X.14X.7X/~repos/erotika.git/ erotika
Initialized empty Git repository in /home/zajdan/erotika/.git/
Password:
fatal: '/repos/erotika.git': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
zajdan#cyberFuture:~$
solution:
zajdan#cyberFuture:~$ git clone ssh://nette#19X.16X.14X.7X/~/repos/erotika.git/ erotika
after tilde there must be a slash!

I have exactly the same issue.
I don't use Putty (just Cygwin).
I use Windows 7 Ultimate (fully patched as of this moment).
I just installed Cygwin yesterday.
I made sure binary mounts were being used.
If I copy a git repo to the machine (via samba mount), I can clone it, but when I "git diff" after the clone, there are a bunch of "different" files with no diffs. After a "git status" there was no output from "git diff". It seems like a newline thing, but I can't figure out how that would be happening. (I have igncr in SHELLOPTS, but removing that doesn't fix it.)
I'm completely stumped.

Check the openssh version you're using in CygWin. Version 5.5p1-1 (which is the latest at this time) gave me the same error. Downgrading to 5.4p1-1 fixed the problem.
Another solution would be to use putty/plink instead of openssh.
For more details, see this thread: http://www.mail-archive.com/cygwin#cygwin.com/msg103752.html

I get message: "remote end gung-up, unexpected EOFs, index-pack failed" while cloning git repo but was able to workaround this issue with copssh http://sourceforge.net/projects/sereds/files/Copssh
The root cause is Cygwin openssh package.
I removed original openssh from Cygwin, installed copssh and set GIT_SSH variable to point copssh binaries. After this I simply added copssh binaries in the PATH and now I'm using copssh instead of openssh - there is no difference.
Everything works fine and issue does not appear any more.
The other solution is to use mSysGit package.

I believe the real problem is that cygwin's ssh looks for .ssh in /home/name/.ssh and mingw's git ssh looks for .ssh in c:/user/name/.ssh
Chances are your keys are in one and only one of these directories.
You can trying telling cygwin's .ssh to use a different identity file using the -i switch, or move the keys into both directories, or create an ssh config file in /home/name/.ssh/config.
I created a config that contains:
Host github.com
User jerryasher
Hostname github.com
IdentityFile c:/Users/jerry/.ssh/id_rsa
And given that I can use either the mingw git from git bash or cygwin's git from an rxvt to interact with github.

To correct this issue, run "plink -agent github.com"
Press y when prompted to cache the key. Login as git. You'll automatically be disconnected. And it sould work.
Source: http://devlicio.us/blogs/sergio_pereira/archive/2009/05/06/git-ssh-putty-github-unfuddle-the-kitchen-sink.aspx

Try to use absolute path to repo in a URL, that worked for me.
Instead of:
git ssh://user#host:port/myapp.git
Write:
git ssh://user#host:port//home/user/repo/myapp.git
Notice the double slash!

Related

Clone submodules on Windows Powershell not possible

I have a project with a submodule configured. It uses a relative path, so it should be checked out via ssh (because I cloned the parent project with ssh).
I did:
git submodule update --init --recursive --remote
and the error is on Windows Powershell: Permission denied
I think I also found the reason for this. My ssh key is protected with a password. So powershell should ask me for the password as it does when using git clone. But apparently it does not.
So I got a few workarounds:
Use git bash on Windows (asks me for the passsword and thus works perfectly)
Don't use a password for ssh
Don't use ssh
All workarounds are not ideal. So I wonder: Is this a known issue / limitation? Can I do anything about this?
If those submodules are using an SSH URL (check your .gitmodules), then you can try and use an ssh-agent in your Powershell session.
Test it with ssh -Tv remoteUser#remoteServer (for GitHub remote repositories, that would be ssh -Tv git#github.com)
The first query should ask for your SSH passphrase, but after that, you should be able to clone/submodule update without any more prompt.

git ssh authentication fails with ssh_askpass: posix_spawn: Unknown error

I am using a setup on Windows 10 x64 where I install and manage git via scoop, rather downloading and executing the installer myself. Via the PowerShell, I ran
scoop install git
scoop install openssh
[environment]::setenvironmentvariable('GIT_SSH', (resolve-path (scoop which ssh)), 'USER')
However, now when I try to run commands in the Git Bash like
git clone git#example.org:vendor/repository.git
or a simple
git push/pull
I only get
CreateProcessW failed error:193
ssh_askpass: posix_spawn: Unknown error
instead of the Git Bash asking me for my SSH key's passphrase.
I am using the same setup (git installed via scoop) on many other Windows 10 x64 and no problems occur there. So I am not sure what is going wrong on this one. I previously had git installed without scoop on the same machine and the Git Bash was working fine. I uninstalled git completely (and also restarted the machine, just to be sure) before re-installing it via scoop instead.
The SSH_ASKPASS environment variable contains the following, in case this is relevant:
$ echo ${SSH_ASKPASS}
/mingw64/libexec/git-core/git-gui--askpass
Not sure what that folder refers to (something internal to the Git Bash presumably?), since it obviously does not exist like that on my machine.
Update
When using git-with-openssh instead of just git and openssh separately it works. However, I don't use that on my other machines, so I'd still like to know why it's not working here.
I'm pretty sure my answer does not address the OP's original case. But as of 2020, there seems to be a similar issue with a different way of solving it, and that's how I did in my case.
Part of the problem is, now Windows 10 has its own version of OpenSSH available, and at least in the case of my work's machine it seems that option is enabled by default.
This bundled OpenSSH is not compatible with Git bash though, so if you wants to use it, you must force git use scoop's provided OpenSSH (either from openssh or git-with-openssh packages). That means overwriting GIT_SSH environment variable, e.g. by adding a line similar to this to your .bashrc:
export GIT_SSH='C:\Users\rogs\scoop\apps\git-with-openssh\current\usr\bin\ssh.exe'
Hope it helps.
Even if this topic is already very old, the problem persists. I found out that its enough to simply unset the environment variable to get rid of this error.
unset SSH_ASKPASS
Just put this in your .bash_profile and/or your .bashrc.

Does SSH server need to be running in a unix style environment on remote client for GIT clone to work?

I am tasked to set up a central GIT repo internally for my team.
I'm working on getting this setup on a Windows Server 2012 R2 machine. To the best of my knowledge I've set this up correctly.
I have been following this tutorial but they use CopSSH which isn't free anymore so instead I installed Windows OpenSSH here: Install-Win32-OpenSSH.
On our windows server I've installed and configured the Windows OpenSSH along with GIT. Made the appropriate changes with regards to the environment variables and references needed.
On my local system (also windows) I've installed Putty and generated my public and private keys. The public key has been copied to the server and placed in the correct file. Using putty, I have verified my public/private key authentication is working.
On the server I created a git bare repository in the C: drive like so:
cd C:\
mkdir testing.git
git init --bare testing.git
I installed GIT on my local machine and run the command:
git clone ssh://name#host:port/testing.git
I always end up with the output:
Cloning into 'testing'...
fatal: ''/testing.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.
I've tried different variations of this command with the same results and moving the testing.git file to the user home directory (C:\Users\name):
git clone ssh://name#host:port/c/testing.git
git clone ssh://name#host:port/~/testing.git
I've messed with permissions to explicitly give permissions for this user to access that directory.
It seems as though, maybe the git clone command cannot find the folder on the remote server. I started thinking that the SSH server itself needed to be running in a unix like environment like cygwin. Is this my issue? I've seen tutorials/walkthroughs of installing cygwin with openssh and this would be my next attempt.
Thanks for any help!
EDIT:
So I went ahead and installed Bitvise with their 30 day trial (to try) and everything works but this is only for 30 days. So this must mean that there is some set up issue with the Windows OpenSSH that I have?

"Failed to add the host to the list of known hosts" Windows prompt

I wanted to try and use git in my regular Windows prompt instead of in Git Bash. Simply for the reason that I could then use the terminal that IntelliJ provides. I figured it to be a 1 minute fix but I guess not.
When I try to git pull origin <branch> I get the following error message:
C:\Users\Username\Documents\Bitbucket\java-project>git pull
Could not create directory '/c/Username/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 12:8c:1b:f2:6d:14:6b:5c:3b:ec:aa:46:46:xy:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Username/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have set the permissions on the existing .ssh folder such that all Users have full access, administrators and SYSTEM. So that should be okay.
I also tried to run the prompt as Administrator to see if that was the issue but that's not the case either.
What I do notice now is that it says: Could not create directory '/c/Username/.ssh'.. However, my .ssh directory is located at C:\Users\Username\.ssh. I might need to change my configuration then.
Git version: 1.9.0.msysgit.0
Windows version: Windows 8.1
First of all, tested with msysgit 1.9.2, when one selects to make just git command available from cmd.exe during installation (where other choices are, make it avaiable only under git bash, or make all MSYS commands available under cmd.exe), git clone works from cmd.exe prompt.
The ssh client uses HOME environment variable to find .ssh/ directory, but git should take care of all the ugly details. You should not have HOME defined in your normal Windows environment, so if echo %HOME% in cmd.exe prompt prints a path, edit the OS environment variables and remove HOME.
If that does not solve it, uninstalling and installing latest version might help.
Finally, you have paths like C:UsersUsername, it probably means you're missing quotes somewhere. In git bash, try these two commands to see:
echo C:\Users\Username
echo 'C:\Users\Username'
Make sure you type your cmd session the git-cmd.bat which comes with every Git For Windows msysgit release.
That will set your HOME to %USERPROFILE%, which should be C:\Users\Username.
But make sure you didn't have an environment variable HOME already defined with an incorrect value: unset it if that is the case.
Open Git Bash console.
Perform the command below to enable read and write;
chmod 776 your local path here/known_hosts
More details here

ssh authenticated git access at windows command prompt?

There are many fine instructions about how to work with git under windows using GitBash.
I note that when git is installed, it offers the option of "set up for using git from the windows prompt", which puts git on the windows path.
Is there some way to set this up so that ssh authentication works?
At the moment I get "permission denied (publickey)" when I try to do git commands that access the remote.
(edit) I have set %HOME% to point to my Windows home directory, and there is a .ssh folder in there with id files that work under a gitbash shell.
I appreciate that the answer is likely "no, this is why GitBash exists". But - it would be good to know for sure.
If the answer is "no" it kinda makes you wonder why you would bother putting git on your windows path?
ssh access works fine from a regular DOS session.
You only need to define C:\Users\YourAccount\.ssh and add your id_rsa and id_rsa.pub there.
Launch your git session through git-cmd.bat, which will define %HOME% to your C:\Users\YourAccount: that is what will make ssh work.
This should put your msysgit/bin installation in your PATH.
I really recommend not installing through a msi (Microsoft Installer), but through a simple unzip of an archive (portable version "PortableGit-x.y.z-preview201ymmdd.7z")
And the OP GreenAsJade's comment points out the fact that GIT_SSH must point to plink.exe.
Well, maybe I have a process that seems to work.
If you use a passphrase during the generation of the keys, you'll have to type this passphrase after loading an ssh-agent and add the key to the agent.
Basically, the solution is: follow the instructions on this page:
https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
BUT, during the generation of the keys DO NOT TYPE A PASSPHRASE.
Obviously, it's 'weaker' from a security point of view.
But, the .bashrc script will work as expected (loading the identity on git bash startup).
You can use then the "start-ssh-agent.cmd" script located on Git\cmd folder. It will open a Dos Prompt with the identity loaded and everything will work!

Resources