1 台のデバイスで複数のリポジトリ アクセス キーを管理する

SSH 経由で複数の Bitbucket Cloud リポジトリにアクセスする必要があるツールやスクリプトがある場合に、デバイスに複製された各リポジトリの正しい SSH キーによって Git が Bitbucket に接続するためには、いくつかの追加設定が必要です。

読み取り専用のリポジトリ アクセス キーを使用して複数のリポジトリにアクセスするようにデバイスを設定するには、次の手順に従います。

  1. SSH がインストールされていることをご確認ください (お使いのオペレーティング システムに関連する SSH セットアップ ガイドをご参照ください)。

  2. ~/.ssh/ ディレクトリ内のリポジトリごとに次のような SSH キー ペアを作成します。

    cd ~/.ssh/ ssh-keygen -t ed25519 -b 4096 -C "{username@emaildomain.com}" -f {ssh-key-name}
  3. 公開キーを Bitbucket Cloud の対応するリポジトリに追加します (お使いのオペレーティング システムに関連する SSH セットアップ ガイドをご参照ください)。

  4. Create or update each repository’s .gitconfig (not the user’s global Git configuration at ~/.gitconfig) to include the core.sshCommand setting, with an ssh command that uses the private key for the repository, such as:
    ~/repository1/.gitconfig

    [core] sshCommand = ssh -i ~/.ssh/repository1_private_ssh-key-name

    ~/repository2/.gitconfig

    [core] sshCommand = ssh -i ~/.ssh/repository2_private_ssh-key-name
  5. ユーザーのグローバル Git 構成ファイル ~/.gitconfig を更新して、includeIf 設定を使用してリポジトリの Git 構成ファイルを条件付きで含めます。次に例を示します。

    [includeIf "gitdir:~/repository1/"] path = ~/repository1/.gitconfig [includeIf "gitdir:~/repository2/"] path = ~/repository2/.gitconfig

さらにヘルプが必要ですか?

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