TIL

Git アクセスするときの SSH 形式

Git SSH

Git を複数アカウント使い分ける時、 SCP スタイルの構文の SSH を使わないといけない。

 git@github-sub:sub_account_id/til.git                  
                   
              └── リポジトリ名  
                    └── オーナー/組織名
   └── SSHホスト (Host)
  └── SSHユーザー名

github-sub という Host 名を指定する。

これは ~/.ssh/config で定義されているものだ。

Host github github.com
  HostName github.com
  IdentityFile ~/.ssh/id_ed25519
  User git

Host github-sub
  HostName github.com
  IdentityFile ~/.ssh/sub_account_key
  User git

← Back