Bamboo fails to add Bitbucket Server repository: "Can't authenticate with Bitbucket Server despite successful public key storage"

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.

Summary

When adding/saving a Bitbucket Server linked repository in Bamboo, the following error message shows up:

Could not access this repository in Bitbucket Server

Bamboo was unable to verify connection to this repository. It might have been moved, deleted, or the current SSH key was revoked on Bitbucket Server. Click Save repository at the bottom of this screen to attempt to re-establish access to this repository.

Environment

Bamboo 7, 8, 9.

Diagnosis

Looking at the logs, the following errors can be seen:

INFO [https-jsse-nio-8443-exec-18] [BitbucketServerServerConfigurator] Public key was added to Bitbucket Server (Bamboo user: admin, application: Bitbucket [https://git.repository], location: repository BP/bamboo-build-specs): ssh-ed25519 AHSJJRBBNSJSHDI1NTE5AAAGDHSIIQTOX/Ikendfganth0936+Ajdjdqpitsb https://repository.example
WARN [https-jsse-nio-8443-exec-18] [CacheAwareness$1] Inheriting disabledCaches:[com.atlassian.bamboo.ANY]
WARN [sshd-SshClient[7344e4e5]-nio2-thread-4] [LoggingUtils] exceptionCaught(ClientSessionImpl[git@git.repository/145.199.133.181:7999])[state=Opened] SshException: Server key did not validate
INFO [https-jsse-nio-8443-exec-18] [BitbucketServerServerConfigurator] Can't authenticate with Bitbucket Server despite successful public key storage: ssh-ed25519 AHSJJRBBNSJSHDI1NTE5AAAGDHSIIQTOX/Ikendfganth0936+Ajdjdqpitsb https://repository.example

Cause

The root cause can be one of the following:

  • If the Managing Trusted key is enabled in Bamboo;
  • If the user that created the Linked repository is deactivated;
  • When the access key is missing in the Bitbucket repository;
  • When Bitbucket is offline;
  • When the Application link is not properly configured;
  • When the repository has been removed or its name has been changed;
  • If a capability is not listed in Bamboo.

Solution

Please check the following solutions:

  • Check Manage trusted keys
    • Option 1: Disable the option 'Manage Trusted key' on  Bamboo Administration > Security > Security settings > Global security and permission properties, if not in use.
    • Option 2: Add the Repository SSH Host key to the Trusted keys. E.g:

      • Capture Bitbucket's SSH host public key:

        $ ssh-keyscan -p7999 bitbucket 2>/dev/null [bitbucket]:7999 ssh-rsa AHSJJRBBNSJSHDI1NTE5AAAGDHSIIQTOX......kendfgant

      • Add it to the Trusted Keys: Bamboo Administration > Trusted keys > Add keys where:
        • Host=<hostname>:<port> => bitbucket:7999
        • SSH key=<key type> <ssh host key> => ssh-rsa AHSJJRBBNSJSHDI1NTE...

  • Save the repository:
    • Make sure you are an admin user in Bitbucket because when a non-admin user saves the Linked repository and for whatever reason is deactivated, the Linked repositories will fail due to connections being based on that user's credentials.
    • Go to the Bamboo Linked repository, save the repository to a different project/repository and save it back to the original one.

  • Check Bamboo capabilities 
    • The issue can happen when a Git capability is not set on Bamboo and it impacts directly on the agents and builds execution. Please access Bamboo Administration > Overview > Server Capabilities and press 'Detect Server Capabilities'. This will force Bamboo to load all capabilities available.


Last modified on Oct 12, 2022

Was this helpful?

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