git配置多个ssh key

旧城冷巷雨未停 提交于 2020-03-10 08:38:46

生成一个ssh key


ssh-keygen -t rsa -C “xxx@aabb.com” # 根据你的邮箱采用rsa非对称算法生成一个ssh的公钥和私钥 

将生成的私钥加入到ssh中

ssh-add ~/the/private/key # 后面填写私钥的路径

配置ssh

TCPKeepAlive=yes
ServerAliveInterval 60

# gitlab
Host gitlab.xxx.com # your gitlab hostname
port 22
HostName gitlab.xxx.com
PreferredAuthentications publickey
IdentityFile ~/.ssh_gitlab/rsa.pub
User yourGitLabName


# github
Host github.com
Port 22
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/rsa.pub
User yourGitHubName
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!