.ssh/config
お仕事用と趣味でリポジトリを分けている。
原則リポジトリ毎に鍵を管理したいので、複数リポジトリ毎に鍵を分ける。
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
port 22
Host github.com.private
HostName github.com
IdentityFile ~/.ssh/id_rsa_github_private
User git
port 22
Host名を分ければよい。
$ ssh -T github.com.private
Hi private_account! You've successfully authenticated, but GitHub does not provide shell access.
クローンできた。
$ git clone git@github.com.private:private_account/repository.git
設定
必要に応じて設定が必要。
ユーザ情報
$ git config user.name "private_accountのユーザーネーム"
$ git config user.email "private_accountのメールアドレス"
リモートURL
$ git remote add origin git@github.com.private:private_account/repository.git
$ git remote set-url origin git@github.com.private:private_account/repository.git