Help us understand the problem. What is going on with this article?

GitHubのアカウントを複数SSH接続する

More than 3 years have passed since last update.

よく忘れていっつもググるから自分用メモ。

公開キーの確認

$ cd ~/.ssh/
$ ls

id_rsa.pub、id_rsaがあったりする。

鍵を作成する

$ ssh-keygen -t rsa -f [file name] -C 'mail address'
# -C は設定しなくてもOK。しなかったらマシン名が設定される
# Passphraseは必要なら入力する

公開鍵をコピー

$ pbcopy < ~/.ssh/[file name].pub

公開鍵をGitHubに登録する

https://github.com/settings/ssh

にコピーした公開鍵を登録する。

Hostを指定する

$ vim ~/.ssh/config

に以下のように記載。

Host itigoppo.github.com
  User git
  Port 22
  HostName github.com
  IdentityFile ~/.ssh/github_itigoppo_rsa
  TCPKeepAlive yes
  IdentitiesOnly yes

接続テスト

$ ssh -T itigoppo.github.com

リポジトリにアクセスする

git@[host name]:[account name]/[repository name].git
の[host name]をconfigに設定したhostに変更する。

# 通常はこう
git@github.com:itigoppo/repository.git
↓
# 別のアカウントとしてSSH設定したやつはこう
git@itigoppo.github.com:itigoppo/repository.git
itigoppo
ぱんだだよーの人。
http://www.nono150.com/
cookbiz
「フード」「HR」「IT」をキーワードに、飲食に特化した求人サイトと人材紹介サービスを展開
https://cookbiz.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした