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アカウント利用時のメモ

Posted at

複数GitHubアカウントの利用メモ

概要

githubで複数アカウント(私用、仕事用など)を利用している場合に各プロジェクトで正しくリポジトリを参照できるようにする。

SSH鍵の管理

SSHエージェントの起動確認

eval "$(ssh-agent -s)"

プロセスIDが表示されればOK

Agent pid 12345

登録されている鍵の確認

ssh-agent に私用、仕事用などの鍵が登録されているか確認。

ssh-add -l

鍵の登録

ssh-add ~/.ssh/[秘密鍵へのパス]

再度確認

ssh-add -l

接続確認

ssh -T git@[~/.ssh/config で指定した Host名]
Hi xxxxxx! You've successfully authenticated, but GitHub does not provide shell access.

正しいユーザ名が表示された場合は、接続OK

macOSでのssh key の設定

キーチェーンに ssh key を保存しPC起動時に読み込む。

キーチェーンに保存

ssh-add --apple-use-keychain ~/.ssh/[秘密鍵へのパス]

PC起動時に読み込む

~/.zshrc で読み込む

# キーチェーンから鍵を読み込む
ssh-add --apple-load-keychain

Gitの接続先の確認

リモートURLを確認

正しくリポジトリが参照できているか確認する

git remote -v

メモ

config 例

~/.ssh/config

Host github-personal
    HostName github.com
    User [ユーザー名]
    IdentityFile ~/.ssh/[秘密鍵]
    IdentitiesOnly yes # IdentityFileで指定した秘密鍵のみを使用する
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?