生成sshkey ssh-keygen -t ras -C "youremail@yourcompany.com" 這時能夠一路回車,不輸入任何字符,將自動生成id_rsa和id_rsa.pub文件。 生成並添加第二個ssh key ssh-keygen -t rsa -C "youremail@gmail.com" : 這時不能一路回車,不然郵箱將覆蓋上一次生成的ssh key,給這個文件起一個名字, 好比叫 id_rsa_github,因此相應的也會生成一個 id_rsa_github.pub 文件。 添加ssh key $ ssh-add ~/.ssh/id_rsa $ ssh-add ~/.ssh/id_rsa_github 在 ~/.ssh 目錄下新建一個config文件 touch config # gitlab Host gitlab.com HostName gitlab.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa # github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_github 測試 $ ssh -T git@github.com 轉自:
轉自:http://www.html-js.com/article/The-frontend-development-tool-githubgitlab-and-manage-multiple-SSH-keyjavascript