Git with SSH authentication fails
Asked by Vlad Ion:

Hi,

I have a problem accessing a Git repository with SSH authentication in Bamboo 5.5.1. I found some related issues from older versions of Bamboo that state they were already fixed in versions before 5.5. Still I get this error in Bamboo:
> *Unable to detect changes*  
> (com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command C:\\cygwin\\git\\bin\\git.exe ls-remote ssh://4a28d11b-560e-4775-a591-97b389d7ecd0@127.0.0.1:57994/path_to_repository failed with code 128. Working directory was \[.\]., stderr: Authenticating remote session failed stdout: \[BAMBOO-SSH-PROXY: \[While connecting to \[user@/gitserver:22\]: Authenticating remote session failed\], fatal: Could not read from remote repository., , Please make sure you have the correct access rights, and the repository exists.\])  
> (24 Jul 2014, 12:59:38 PM)

This is frustrating because the Bamboo built in git works fine with the same repository (I just set the private ssh key and it all works), but I need submodule support. I tried various versions of native git and they all fail the same way. I first tried msysgit 1.9.4 ([git-scm.com](http://git-scm.com)), then cygwin git, then I compiled the latest 2.0.3 git in cygwin and used that. They all give the same error. I even tried the msysgit 1.9.4 with the cygwin ssh (seeing that the cygwin ssh is a newer version) by defining the ssh capability. Seems like the problem is related to the SSH part and the Bamboo ssh proxy thing, but I can't figure out what I can do about it.

I tested Bamboo in the past, version 5.0 I think, that didn't have submodule support at all, but native git (msysgit 1.8.4 I think) worked fine at that time.

Thanks,

Vlad


Answers:
author: Vlad Ion
body: I figured out the problem. It was a firewall between the computer running Bamboo and the one running the Git repository. I moved Bamboo to a computer behind that firewall and git+ssh works fine, including getting the submodules, so all is good.

I'm curious now about what the Bamboo ssh proxy does differently compared to the native ssh connection so that it makes the firewall block it. I would guess the connection is the same: from my-computer:random-port to git-server:22, so it must be some other criteria than ip:port filtering.

comments: author: Vlad Ion
body: The problem doesn't seem to be the firewall itself, the ssh connection goes through to the git server, but drops immediately after a succesful authentication. Maybe it's the fact that the connection is done through VPN.


author: Krystian Brazulewicz
body: There are some most common problems with Windows-ssh-git trio. Things to check:

* make sure it works from command line
* if your Bamboo is run as a system service make sure there's HOME environment variable set for system account

If it still doesn't work contact our support <https://support.atlassian.com/servicedesk/customer/bsp>

comments: author: Vlad Ion
body: Thanks. I tried from the command line, everything works well, I can clone or run ls-remote (without the ssh proxy thing of course). I run bamboo in the console under my windows user.

I also tried on a clean virtual machine, command line works, Bamboo doesn't.

I am just testing Bamboo for now with an evaluation license so can I contact support if I'm not a customer yet?


author: Krystian Brazulewicz
body: Yes please do.


author: Vlad Ion
body: Ok, great. I've got this reference: [**BSP-14660**](https://support.atlassian.com/browse/BSP-14660)


author: whtank
body: Thanks Krystian, I also encounter a problem on Win8 that can't sync submodule, but it works after set %HOME% env var