Unable to detect changes: Authenticating remote session failed

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

The following error message is observed inside the <bamboo-home-directory>/atlassian-bamboo.log file or through the Bamboo UI:

INFO [10-BAM::PlanExec:pool-17-thread-1] [DefaultErrorHandler] Recording an error: Unable to detect changes : FOO-BAR3 : com.atlassian.bamboo.plugins.git.GitCommandException: command /usr/bin/git ls-remote ssh://0df49214-5e55-382a-2d45-1cce68b3547f@127.0.0.1:43801/project/repo.git failed with code 128. Working directory was [.]., stderr:
Authenticating remote session failed
stdout:
Warning: Permanently added '[127.0.0.1]:43801' (RSA) to the list of known hosts.
BAMBOO-SSH-PROXY: [While connecting to [git@webserver.stash/192.168.10.79:7999]: Authenticating remote session failed]
fatal: The remote end hung up unexpectedly

Diagnosis

To reproduce this problem you must have Bamboo Server linked to Bitbucket Server (formerly Stash) via application link, and your repositories are Bitbucket Server / Stash type. It's difficult to pinpoint the symptoms of this problem if you don't dive deeper. Most the time you'll see errors in the UI but it will seem that Bamboo is working as expected. It's usually unclear as to whether this is truly causing problems or not.

Cause

The following are possible causes of this problem:

1. Branch doesn't exist in the source repository

Most of the time this error happens because the branch was removed in the source repository but the corresponding Plan branch was not removed from Bamboo. When Bamboo polls the repository for changes this error occurs because the repository branch doesn't exist.

2. SSH keys are not up-to-date anymore

Another cause of this is when the SSH keys are removed under a particular user. To expand on this as an aside for a moment, I'll explain briefly how authentication works when Bamboo is linked to Bitbucket Server (PKA Stash).

When creating the repository definition in Bamboo (either via "Plan configuration >> Repositories" or "Bamboo administration >> Build resources >> Linked repositories") Bamboo creates an SSH key pair and stores the private key in the repository configuration. It then uploads the public key to Bitbucket Server (PKA Stash):

  1. If the user creating the repository configuration has administrative access to the target repository, Bitbucket Server (PKA Stash) will store the public key as one of the repository access keys. This is the recommended approach.
  2. However, if the user doesn't have administrative access to the target repository, it will create the repository definition inside Bamboo and then store the public key in Bitbucket Server (formerly Stash) as one of the user profile keys.

The first option only became available with Bamboo 5.10.x. If you are running a previous version of Bamboo, every time a user creates a repository definition in Bamboo, the public key is stored under that user's profile. The problem with this is: if the user that created the repository definition gets removed or has the access to the repository revoked, for example, Bamboo will start failing to detect changes with authentication errors.

3. Connectivity & Application status

Lastly, we also observe errors like this one when Bamboo is unable to reach out to Bitbucket Server (PKA Stash). Please check and ensure that Bitbucket Server (formerly Stash) is reachable from Bamboo and vice versa. You can check this using ping. An example is something like "ping your_host". Also please ensure that Bitbucket Server (formerly Stash) is not down or in maintenance mode.


To sum up, the possible causes are:

  1. The branch has been removed in the source repository.
  2. The user who created the repository definition (or the user's SSH keys) were removed.
  3. Bitbucket Server (formerly Stash) is down or in maintenance mode or cannot be reached from the Bamboo Server.

Resolution

Depending on which possible cause applies, the following resolutions may be applicable:

  1. Ensure that the branch has not been removed from the source repository. Please navigate to the Plan branch configuration in Bamboo and inside the Source Repository tab take note of the branch associated to the Plan branch. Access Bitbucket Server (formerly Stash) and confirm that the branch exists there.
  2. If the branch exists in the source repository, this might be related to Bamboo not being able to authenticate to Bitbucket Server (formerly Stash), as per the SSH keys section above. In this case, please re-save the repository definition inside the plan branch configuration in Bamboo and check if the "Unable to detect changes" errors will go away for that particular branch. Once you re-save the configuration, new SSH keys will be generated with your user, so Bamboo should be able to authenticate to Bitbucket Server (formerly Stash) to look for changes in that particular branch going forward.

    Please bear in mind that if you re-save the repository configuration at the global level ("Bamboo administration >> Build resources >> Linked repositories") or even at the Plan level ("Plan configuration >> Repositories") this will not affect the plan branch repository definition. You must access the plan branch repository definition to save the configuration. In case you're having problems to run the main branch of the Plan, then you can access ("Plan configuration >> Repositories" or "Bamboo administration >> Build resources >> Linked repositories") to re-save the repository definition.


Last modified on Oct 15, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.