LoginSignup
4
0

More than 5 years have passed since last update.

Githubの複数リポジトリ毎に鍵を分ける

Posted at

.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
4
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
4
0