SSH port on GIT Repository Polling
Asked by Keith Naas:

We have a build plan configured against an internal git repository where it uses periodic repository polling for changes*.* When the build executes the first time after the Bamboo daemon starts, it hangs on checkout. We have determined that this is because the git ssh connection does not trust the host fingerprint. In order to fix it we have to open a terminal and run the git command using the information in the builds log (see below). It looks like it is abstracting the actual repository away from the build execution.

Is there a way to force bamboo to use a single port for ssh instead of it randomly picking one each and every time the bamboo daemon is started? Or is it possible to somehow configure bamboo to not use ssh for its internal polling? Or is it possible to configure the ssh task to auto accept the fingerprint?

Here is what shows in the log when we Stop the build and forcefully kill the build process. We then execute "ssh 2213afe7-34d0-48f2-b0b2-a001f813d8bb@127.0.0.1:1124" to allow us to accept the host fingerprint.

Executing Task 'Checkout Default Repository(3)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout.  
(java.lang.RuntimeException : com.atlassian.bamboo.plugins.git.GitCommandException: command \[E:\\dev\\git\\git-1.7.9.preview20120201\\bin\\git.exe, fetch, ssh://2213afe7-34d0-48f2-b0b2-a001f813d8bb@127.0.0.1:1124/dsw-com-env, +refs/heads/2.7.0-SNAPSHOT:refs/heads/2.7.0-SNAPSHOT, --update-head-ok\] failed. Working directory was \`E:\\BH\\xml-data\\build-dir\\_git-repositories-cache\\331d3864477b6b63a40bcb4eaf5c0c8452254a8f'. stderr: stdout: )


Answers:
author: PiotrA
body: I think you're hitting a bug in Bamboo. <https://jira.atlassian.com/browse/BAM-11096>

The desired Bamboo behavior is that it manages to 'invisibly' replace the known fingerprints in-fly so no user will have to accept the fingerprints manually. Seems to me it doesn't work on Windows machines. At least not on every.

Which ssh client do your git.exe use? I assume you are using <http://code.google.com/p/msysgit/> as a git implementation on windows... how had you configured ssh for it?

comments: author: Keith Naas
body: That looks to be the issue. We use msysgit and all of the goodies that come with it. If you look at the task manager you can see that git.exe kicked off ssh.exe to grab the updated code. I noticed that it only seems ot happen when Polling Repository for Changes. If we only do manual build strategy the issue doesn't happen, probably because it connects directly to the ssh server instead of through a custom ssh connection. It would be nice if when setting up the build plan's git ssh connectivity that it attempted to access the server immediately and then let you accept the host fingerprint from there.

The msysgit git install folder contains a .ssh\\known_hosts file that shows the fingerprint. It would be pretty easy for bamboo to automatically add it to that file.

\[127.0.0.1\]:4657 ssh-rsa AAAAB3NzaC1

\[127.0.0.1\]:1124 ssh-rsa AAAAB3NzaC1


author: PiotrA
body: bq. "If we only do manual build strategy the issue doesn't happen"

That's weird, because (regarding to this issue) there are no differences in "Polling Repository" and "Manual Build" strategies - git commands run by Bamboo would be the same in both scenarios. Can you confirm that it is the same plan failing when run with "polling repository" strategy and succesful when its strategy is set to "Manual" and you run the build manually?


author: PiotrA
body: Keith,

I confirm there exist a bug in Bamboo ([BAM-11096](https://jira.atlassian.com/browse/BAM-11096)) and we are trying to fix it before Bamboo 4.0. However, if you need to workaround the problem sooner you should manually edit your .ssh\\known_hosts file (in msysgit git install directory I presume) and add:

```
127.0.0.1 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC699HzXHwr1H6OJeVlRo7h4r+3PYd0wNkqzl6EUAeU2iZjqFqQL2ZiNVqs2JrpTNduipXBNk9rhQIWajQZG9ZJG/OPxe+NOkbWQVevrcELsw5N2wxcJOWz+ey1tFv3VCtNCLUGgF7yIg0kWWVQ+HvAzLoMbiHs0haVmEjnLherSw==
```

That way you won't have to open terminal and run the git commands manually each time Bamboo starts its ssh deamon.


author: Ryan Goodwin
body: For those not specifically running into ssh errors, msysgit needed some help after being installed.

<http://stackoverflow.com/questions/3431361/git-for-windows-the-program-cant-start-because-libiconv2-dll-is-missing>


Tags: git

ssh