New access key is required but could not be added to Bitbucket Server

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

問題

Adding a Bitbucket Server repository to Bamboo fails. The following appears in the atlassian-bamboo.log

2016-02-15 17:42:58,262 INFO [http-nio-8085-exec-18] [StashRepository] Public key was added to Bitbucket Server (Bamboo user: admin, application: Bitbucket [http://bitbucket.url], location: repository PROJECT/reponame): ssh-rsa xxx... http://bamboo.url
2016-02-15 17:42:58,709 WARN [sshd-SshClient[ffd7a43]-nio2-thread-3] [AcceptAllServerKeyVerifier] Server at bitbucket.urk/xxx.xxx.xxx.xxx:22 presented unverified EC key: xx:xx:xx...
2016-02-15 17:42:58,803 WARN [Connection killer] [SshProxyCommand] While connecting to [git@bitbucket.url/xxx.xxx.xxx.xxx:22]: Authenticating remote session failed
2016-02-15 17:42:58,920 INFO [http-nio-8085-exec-18] [StashRepository] Can't authenticate with Bitbucket Server despite successful public key storage: ssh-rsa xxx... http://bamboo.url

または

2016-06-23 13:28:40,541 INFO [ajp-apr-9002-exec-12] [StashRepository] Public key was added to Bitbucket Server (Bamboo user: admin, application: Bitbucket [http://bitbucket.url], location: repository PROJECT/reponame): ssh-rsa xxx... http://bamboo.url
2016-06-23 13:28:40,551 INFO [ajp-apr-9002-exec-12] [GitCommandProcessor] Command was canceled: command /usr/bin/git version failed with code -1. Working directory was [\].

診断

Under normal conditions, and if performed by a user with repository admin privileges (either via Administration > Global Permissions or explicitly under Project Settings > Permissions or Repository Settings > Permissions), adding a Bitbucket Server repository from within Bamboo automatically creates and adds an Access Key into the Bitbucket Server repository and subsequently performs a Git SSH test against the SSH URL of the repository. From the log above, the Access Key is successfully created and added to Bitbucket Server however, the test fails.

  1. Perform a telnet test from Bamboo to the Bitbucket Server SSH Base URL to confirm connectivity.

    $ telnet bitbucket.ssh.base.url 7999
    Trying 192.168.56.102...
    Connected to bitbucket.host.
    Escape character is '^]'.
    SSH-2.0-SSHD-UNKNOWN


    1. Check the Bitbucket Server SSH access settings at Administration > Settings > Server settings. The SSH port value must be appended to the SSH base URL otherwise, the default value, 22, will be used which requires an additional port forwarding configuration to be setup via a (reverse) proxy. For example, the following setup shows that the port is set to 7999 but since the SSH base URL is  ssh://bitbucket.url , this means that using SSH, the repositories can only be reached on port 22 and implies that you've also set up a proxy.

  2. Confirm that a git client is installed on the machine hosting Bamboo and that if defined, that the path to the git executable configured at Bamboo Administration > Build Resources > Server Capabilities is correct.

原因

  1. SSH connection cannot be established between Bamboo and to the Bitbucket Server SSH base URL. Common issues:
    1. SSH access is not enabled on Bitbucket Server
    2. The proxy or load balancer listening at the Bitbucket Server SSH base URL does not redirect TCP traffic from port 22 (default port if no port is added to the SSH base URL) to the SSH port defined in Bitbucket Server.
    3. The Bitbucket Server SSH base URL is incorrect.
    4. Firewall blocking access between Bamboo and the Bitbucket Server SSH Base URL.
  2. Incorrect Git executable path is configured in Bamboo.
  3. Incorrect custom Git SSH executable path is configured in Bamboo.

ソリューション

  1. Investigate and resolve any network or firewall issues that may be blocking the SSH connection between Bamboo and to the Bitbucket Server SSH base URL.
    1. Configure SSH access in Bitbucket Server: Enabling SSH Access to Git Repositories in Bitbucket Server
    2. Configure the proxy or load balancer to redirect TCP traffic from port 22 to the defined SSH port or append the SSH port to the SSH base URL in Bitbucket Server.
    3. Correct the SSH base URL in Bitbucket Server so that Bamboo attempts connections to the right address.
    4. Add firewall exceptions for the SSH connection between Bamboo and Bitbucket Server.
  2. Make sure that the correct Git executable path is configured at  Bamboo Administration > Build Resources > Server Capabilities.
  3. Most environments do not require a custom Git SSH executable path to be defined and will work if it's removed entirely. However, if it is required, make sure that the correct Git SSH executable path is configured at Bamboo Administration > Build Resources > Server Capabilities

    The default value that is set for the SSH executable is system.git.executable.ssh, which is not a valid executable on any system. If an SSH capability is required, please be sure to replace this default.

    More cause

    If the resolution steps mentioned earlier didn't work, and you've updated Java for the new Bamboo upgrades, it would be worthwhile to check the following knowledge base article as well.

    Unable to add new Bitbucket linked repositories in Bamboo with error "com.atlassian.bamboo.executor.CancelException: /usr/bin/git could not be started" 


説明

Adding a Bitbucket Server repository to Bamboo fails with a "Public key was added to Bitbucket Server" error. This page addresses the steps needed to resolve the issue.

製品Bitbucket
最終更新日 2024 年 8 月 21 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.