Bamboo can't authenticate with Bitbucket Server and shows "New access key is required but could not be added"
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the server and data center platforms.
When adding a Bitbucket server repository in Bamboo, an error message appears:
"New access key is required but could not be added to Bitbucket Server.
ssh://project/repo.git:7999/git: invalid private key: [X@xxxxxxxx..."
Bamboo 6.8, 7, 8, 9 running on Linux OS.
Looking at the logs, the following errors can be seen:
2022-09-14 08:34:48,262 INFO [http-nio-8085-exec-3] [BitbucketServerServerConfigurator] Public key was added to Bitbucket Server (Bamboo user: <user_name>, application: Bitbucket [<bitbucket_URL>], location: repository /module): ssh-ed25519 <encrypted key> <bamboo_URL> 2022-09-14 08:34:48,269 INFO [http-nio-8085-exec-3] [BitbucketServerServerConfigurator] Can't authenticate with Bitbucket Server despite successful public key storage: ssh-ed25519 <encrypted key> <bamboo_URL>
This issue can happen when a Git capability is not set on Bamboo Administration > Overview > Server Capabilities, causing Bamboo to use JGit. JGIt has been deprecated since the Bamboo 6.8 release and is not supported in production environments.
You can check if that's the case by generating a Support Zip, and then look for the Git capability inside application-properties/application.xml
<git> <capability>org.eclipse.jgit</capability> <path>N/A</path> <version>N/A</version> <is-executable>false</is-executable> </git>
Install the Git package on the Bamboo machine and restart Bamboo. After that, please validate if the Git executable is detected on Bamboo Administration > Overview > Server Capabilities.
If Git is already installed and hasn't been detected, please access Bamboo Administration > Overview > Server Capabilities and press 'Detect Server Capabilities'. This will force Bamboo to load all capabilities available.
Git should also be installed on any Remote Agents and its location be listed on the OS $PATH so Bamboo can detect it.