不同網站使用不同 SSH 私鑰


簡單記錄一下,
將 SSH 私鑰獨立出來,應用於不同網站的方法
例子如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
1. ssh-keygen -f ~/.ssh/id_rsa.gitcafe
2. ssh-keygen -f ~/.ssh/id_rsa.geakit

輸入 passphrase 時直接 Enter,否則在提交時會要求輸入密碼

3. vim ~/.ssh/config (如果沒有則自己建立,權限為 600)
4. 加入下面的東西

Host gitcafe.com
IdentityFile ~/.ssh/id_rsa.gitcafe
User git

Host geakit.com
IdentityFile ~/.ssh/id_rsa.geakit
User git

5. 之後測試 ssh -vT [email protected]
6. 當看到 identity file 是指定的檔案是則成功
7. 最後將 cat ~/.ssh/id_rsa.xxxx.pub 中的內容複雜到對應網站中即可