概要
GitHubアカウントAにはSSHキーAを、
GitHubアカウントBにはSSHキーBを発行して使用したい。
手順
1. SSHキーAとSSHキーBを、異なる名称で作成する。
terminal
ssh-keygen -t ed25519 -C "<GitHubアカウントA>" -f ~/.ssh/id_ed25519_A
ssh-keygen -t ed25519 -C "<GitHubアカウントB>" -f ~/.ssh/id_ed25519_B
2. ~/.ssh/configを編集する。
~/.ssh/config
Host github.com.A
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_A
TCPKeepAlive yes
IdentitiesOnly yes
Host github.com.B
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_B
TCPKeepAlive yes
IdentitiesOnly yes
3. ~/.ssh/configで設定したHost名で各プロジェクトを git clone する。
terminal
git clone git@github.com.A:<プロジェクトA>/<リポジトリ>.git
git clone git@github.com.B:<プロジェクトB>/<リポジトリ>.git