0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHubアカウントごとにSSHキーを発行して接続する方法

Last updated at Posted at 2025-09-20

概要

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

参考

[備忘] 複数Githubアカウントでssh接続設定(config)を使い分ける手順

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?