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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,782 views 0 6
Read article

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