1 台のデバイスで複数のリポジトリ アクセス キーを管理する
SSH 経由で複数の Bitbucket Cloud リポジトリにアクセスする必要があるツールやスクリプトがある場合に、デバイスに複製された各リポジトリの正しい SSH キーによって Git が Bitbucket に接続するためには、いくつかの追加設定が必要です。
読み取り専用のリポジトリ アクセス キーを使用して複数のリポジトリにアクセスするようにデバイスを設定するには、次の手順に従います。
Check that SSH is installed (see the relevant SSH setup guide for your operating system).
~/.ssh/ディレクトリ内のリポジトリごとに次のような SSH キー ペアを作成します。cd ~/.ssh/ ssh-keygen -t ed25519 -b 4096 -C "{username@emaildomain.com}" -f {ssh-key-name}Add the public keys to the corresponding repositories on Bitbucket Cloud (see the relevant SSH setup guide for your operating system).
Create or update each repository’s
.gitconfig(not the user’s global Git configuration at~/.gitconfig) to include thecore.sshCommandsetting, with ansshcommand 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-nameUpdate the user’s global Git configuration file
~/.gitconfigto conditionally include the repository Git configuration files using theincludeIfsetting. For example:[includeIf "gitdir:~/repository1/"] path = ~/repository1/.gitconfig [includeIf "gitdir:~/repository2/"] path = ~/repository2/.gitconfig
この内容はお役に立ちましたか?