Why would I get an "Error while opening SSH session" error when checking out source code from Stash in my Bamboo plan?

I am running Bamboo (5.7.0) and Stash (3.4.1) on the same machine.  I have set up applications links and have enabled "Trusted Applications", "OAuth", and "Basic Access" in both Outgoing Authentication and Incoming Authentication.  I have a linked a Stash repository in Bamboo.  In my Bamboo plan, my first task is "Source Code Checkout" and I reference the linked repository.  Here's part of the stack trace.  Any ideas?


com.atlassian.bamboo.repository.RepositoryException: java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command /usr/bin/git ls-remote ssh://bd2155f1-ceb1-ffab-87ce-870dffffb824@ failed with code 128. Working directory was [.]., stderr:
Error while opening SSH session
[Warning: Permanently added '[]:59645' (RSA) to the list of known hosts., BAMBOO-SSH-PROXY: [While connecting to [git@stash.domain.com/]: Error while opening SSH session: org.apache.sshd.common.RuntimeSshException: Failed to get the session.], fatal: Could not read from remote repository., , Please make sure you have the correct access rights, and the repository exists.]

1 answer

1 accepted

1 vote
Accepted answer

Hello Mickey,

Thank you for your question.

Based on the information you have provided regarding Application Links, you have set them up using different authentication methods so every time a request is made the same not necessarily gets interpreted in the same way on the other end.

When using Bamboo 5.6+ and Stash 3.2+ we would suggest on creating application link with default settings, so could you remove the existent one and recreate it as per following:

  • The servers have the same set of users and usernames disabled
  • I am an administrator on both instances enabled

will result in application link created with:

  • Trusted Apps authentication disabled
  • OAuth authentication enabled:
    * Allow 2-Legged OAuth enabled
    * Allow user impersonation through 2-Legged OAuth disabled
  • Basic Auth authentication disabled

Important to notice the following should be same used to access the application from your web browser.

  • Hitting Bamboo from your web browser: http://bamboo.base.url

  • Bamboo administration >> System >> General configuration >> Base URL (http://bamboo.base.url)

  • Hitting Stash from your web browser: http://stash.base.url
  • Stash administration >> Settings >> Server Settings >> Base URL (http://stash.base.url)

  • Stash administration >> Settings >> Server Settings >> SSH access
  • * [x] SSH enabled 
  • * [x] SSH access keys enabled 
  • * SSH Port: 7999

In case you continue on experiencing issues, I would suggest you on raising a Support ticket and adding this Question to the tickets description along with a Bamboo Support Zip.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Thanks Rafael.  I deleted the application link and recreated it.  I also verified that the settings you mentioned were correct.  I also needed to open up port 7999 on my hardware firewall as well as my server firewall, even though my Bamboo instance and Stash instance run on the same machine.

Hi I have exactly the same problem, same error message. I used a default link between the two, resulting in the same configuration as you said. In my case I use Bamboo 5.9.1 build 5914 and Stash v3.10.2. What could it be?

Hello Pierre/Rafael, I am also running into the same issue and my versions of Bamboo and Stash are same as one specified by Pierre. Kindly let me know the resolution for the same.

Hello, It seems I simply needed to open the 7999 and 49366 internet facing ports. Altough, like Mickey, I don't understand why.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

158 views 3 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you