2016年4月27日 星期三

Multiple SSH Keys settings for different key with same host

由於連線位置都是155.100.xxx.xxx,但是key不同會產生,第二個相同git無法抓取到資料問題。
所以需要在~/.ssh/config動手腳。

原先:

$ vi ~/.ssh/config
Host 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex1.pem

Host 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex2.pem


$ git clone ex1@155.100.xxx.xxx:proj_1
success

$ git clone ex1@155.100.xxx.xxx:proj_2
Cloning into 'fs/server/warinode'...
FATAL: R any fs/server/warinode fttwsmt DENIED by fallthru
(or you mis-spelled the reponame)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

會發現第二個無法正常clone




修改後:

下方紅色字體為增加內容。

$ sudo chmod 400 ~/.ssh/ex1.pem
$ sudo chmod 400 ~/.ssh/ex2.pem

$ vi ~/.ssh/config
Host ex1 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex1.pem

Host ex2 155.100.xxx.xxx
        Hostname 155.100.xxx.xxx
        User ex1_user
        IdentityFile ~/.ssh/ex2.pem


$ git clone ex1@ex1:proj_1
success

$ git clone ex1@ex2:proj_2
success

沒有留言:

張貼留言