Why?
- 以下記事にて、
~/.ssh/config
内の設定順序について気になった
~/.ssh/config
の設定順序別の挙動
- 複数の公開鍵をよしなに全検索して使用してほしい場合以下の用に書く
- 上から順番に公開鍵が試されるので、先に書いた公開鍵が使用される
- 先に書かれているので
id_rsa.hoge
が使用される
IdentityFile ~/.ssh/id_rsa.hoge
IdentityFile ~/.ssh/id_rsa.fuga
$ ssh -T github-hoge
Hi hoge! You've successfully authenticated, but GitHub does not provide shell access.
- 先に書かれているので
id_rsa.fuga
が使用される
IdentityFile ~/.ssh/id_rsa.fuga
IdentityFile ~/.ssh/id_rsa.hoge
$ ssh -T github-hoge
Hi hoge! You've successfully authenticated, but GitHub does not provide shell access.
- Hostを細かく指定していても、先に書かれているので
id_rsa.fuga
が使用される
IdentityFile ~/.ssh/id_rsa.fuga
Host github-hoge
User git
Port 22
HostName github.com
IdentityFile ~/.ssh/id_rsa.hoge
TCPKeepAlive yes
IdentitiesOnly yes