今までssh-agentしてssh-addするという頭の悪いことをしていたので、もっと普通のやり方。
ホームディレクトリの.sshディレクトリにconfigってファイルを作って以下の内容で保存。
IdentityFileの所にそれぞれの秘密鍵のファイル名を書いておく所がミソである。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host github.com | |
HostName github.com | |
IdentityFile ~/.ssh/github | |
User git | |
Host bitbucket.org | |
HostName bitbucket.org | |
IdentityFile ~/.ssh/bitbucket | |
User git |
この設定をすることでGitHubにpushするときは自動的にGitHubのIdentityFileが使われて、Bitbucketにpushするときには自動的にBitbucketのIdentityFileが使用される。
また、上記設定は.sshディレクトリにはGitHubとBitbucketの認証に使う鍵が置いてあると仮定している。
鍵の名前はそれぞれ
GitHubは
秘密鍵:github
公開鍵:github.pub
Bitbucketは
秘密鍵:bitbucket
公開鍵:bitbucket.pub
であるとする。
それでは快適なGitライフをお楽しみ下さい。
0 件のコメント:
コメントを投稿