Connecting Bamboo to a stash git repo
Asked by Paul DeSousa:

I am trying to connect point bamboo to a stash repo for some time now and I run the plan (which only does a source code checkout from default repo and that's it. The plan says successful and always errors with the following:

[Server Configuration - Puppet Integration](https://cww.comsol.com/bamboo/browse/SC-PI) ? [SC-PI-40](https://cww.comsol.com/bamboo/browse/SC-PI-40) : *Errors getting changes for SC-PI-40*  
(com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command /usr/bin/git ls-remote ssh://f6f0d878-a9a4-4f3e-b5de-fe18d74849cc@127.0.0.1:32922/sc/puppet-server.git failed with code 128. Working directory was \[.\]., stderr: \[Warning: Permanently added '\[127.0.0.1\]:32922' (RSA) to the list of known hosts., fatal: remote error: Repository does not exist, The requested repository does not exist, or you do not have permission to, access it., fatal: The remote end hung up unexpectedly\])  
(06 Jun 2014, 9:02:35 PM)  
Both stash and bamboo list each other under the application links.  
[Bamboo](http://www.atlassian.com/software/bamboo/) version 5.4.2  
Stash v3.0.1


Answers:
author: Paul DeSousa
body: Reinstalled the latest bamboo and made sure the SSH keys were correct and that seemed to work. Still not 100% sure which ID bamboo uses to access stash's repos but it is working so I won't touch that which isn't broken.


author: Peter Van de Voorde
body: Hi Robert,

Could it be that the stash base url is localhost (127.0.0.1) ?   
or that some hosts file is incorrect?

Why is it trying to add 127.0.0.1 to the list of know hosts?

Just wondering if it might indicate the problem.

Best regards,

Peter

comments: author: Paul DeSousa
body: That a Bamboo quirk. On the command line

git ls-remote [ssh://se-git1.example.com:7999/\~robertn/puppet-server.git](ssh://se-git1.example.com:7999/~robertn/puppet-server.git)

I use the fqdn name. Bamboo is implementing an internal SSH proxy for git in order to authenticate properly with remote repository. Which does not appear to work well. Please see this post for why it is going to some unreproducible host connection: [](/questions/288626/bamboo-can-t-get-code-from-linked-stash)<https://answers.atlassian.com/questions/288626/bamboo-can-t-get-code-from-linked-stash>


author: Pepe
body: And as the same user you can clone the same repository to the bamboo server? It looks like the bamboo server/connecting user doesn't have stash's ssh key stored in known_hosts. Manually running the ssh clone will ensure the various connectivity issues are not the problem.

Another possibility is that the repo is empty but less likely since you're trying to build something. I have seen a similar error when changing the repository used in a build or the clone method (http to ssh). Shutdown, clear the bamboo cache, restart, then run a new build (don't re-run a previously failed build).

comments: author: Paul DeSousa
body: The same user? I can log in to the Bamboo server as the same user as I log into bamboo with and do this:

robertn@dev2:\~/.ssh$ /usr/bin/git ls-remote ssh://se-git1.example.com:7999/\~robertn/puppet-server.git

Enter passphrase for key '/home/robertn/.ssh/id_rsa':

d12710d7a01d4be46f9ebe7341b8232cc395ed33HEAD

d12710d7a01d4be46f9ebe7341b8232cc395ed33refs/heads/master

No it is not empty.


author: Pepe
body: Oh so you have to enter your passphrase? That's possibly the issue. Add your ssh key to key-agent (or whatever ssh key management tool your OS uses) so that you aren't prompted for a passphrase when you run ssh commands.

<http://stackoverflow.com/questions/6106137/git-enter-long-passphrase-for-every-push>


author: Paul DeSousa
body: Also I went in and changed it to where there is no pascode and got a success command line git and a failed bamboo get-remote with the exact same error.


author: Mehmet Kazgan
body: I would delete and add app links.


Tags: bitbucket-server