链接地址 https://gitee.com/help/articles/4229#article-header0
Git配置多个SSH-Key
背景
当有多个git账号时,比如:
a. 一个gitee,用于公司内部的工作开发;
b. 一个github,用于自己进行一些开发活动;
解决方法
生成一个公司用的SSH-Key
$ ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitee_id_rsa
生成一个github用的SSH-Key
$ ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/github_id_rsa
在 ~/.ssh 目录下新建一个config文件,添加如下内容(其中Host和HostName填写git服务器的域名,IdentityFile指定私钥的路径)
# gitee Host gitee.com HostName gitee.com PreferredAuthentications publickey IdentityFile ~/.ssh/gitee_id_rsa # github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github_id_rsa
4.用ssh命令分别测试
$ ssh -T [email protected] $ ssh -T [email protected]
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦