~/.ssh/config
に追記:
Host github.com github.*
User git
Port 22
Hostname github.com
Compression yes
ServerAliveInterval 60
TCPKeepAlive yes
IdentitiesOnly yes
ControlMaster auto
ControlPath /tmp/%r@%n:%p
ControlPersist yes
github.hoge
みたいにして秘密鍵を使い分けていても混ざらずに使えました。
MavericksのHomebrewで入れたopenssh 6.7p1
でのみ確認していましたが
CentOS6上ではyumの最新openssh 5.3p1
でControlPersist
は対応できますがControlPath
の%n
表記に対応していないようでした。
Host github.com
Identityfile ~/.ssh/id_rsa
ControlPath /tmp/%r@github.com:%p
Host github.hoge
IdentityFile ~/.ssh/id_rsa_hoge
ControlPath /tmp/%r@github.hoge:%p
ControlPath
項を個別にハードコーディングして対応。