生成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