一台电脑同时添加git和bitbucket两个网站的ssh key
生活随笔
收集整理的這篇文章主要介紹了
一台电脑同时添加git和bitbucket两个网站的ssh key
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
添加第一個ssh key 就不多說了,不懂的可以自己查資料
ssh-keygen -t rsa -C 'email_1@email.com'然后一路enter就好了
假設已經添加好了git的ssh key 。現在要添加bitbucket的ssh key
首先
ssh-keygen -t rsa -C 'email_2@email.com' //同一個郵箱也可以然后指定公鑰的時候,自己命名:例如 /c/Users/Administrator/.ssh/id_rsa_2 (默認名字是id_rsa,假設已經被git用了)
然后一路enter就好了
打開~/.ssh/config文件(沒有則創建),添加一個Host。內容如下
如果是bitbucket
#建一個bitbucket別名,新建的帳號使用這個別名做克隆和更新 Host my_bitbucket HostName bitbucket.org User git IdentityFile ~/.ssh/id_rsa_2.pub如果是git
#建一個github別名,新建的帳號使用這個別名做克隆和更新 Host my_github HostName github.com User git IdentityFile ~/.ssh/id_rsa_2.pub然后,使用ssh-add添加你的新ssh
ssh-add /c/Users/Administrator/.ssh/id_rsa_2如果出現提示:Could not open a connection to your authentication agent.
則先:
下一步,將ssh key id_rsa_2 添加到git/bitbucket上。然后執行git clone
// 假如原始命令是 git clone git@bitbucket.org:somthing/mail.git //那么你應該用如下命令 git clone my_github:somthing/mail.git遺留問題
bitbucket網站,第一天正常,過幾天執行pull命令的時候,出現“Permission denied (publickey)”,最終解決方案是修改config文件
Host bitbucket HostName bitbucket.org User git IdentityFile ~/.ssh/id_rsa_bitHost gitee HostName gitee.com User git IdentityFile ~/.ssh/id_rsa_gitee.pub疑問點:bitbucket上IdentityFile 用的是私鑰,而不是公鑰,暫時沒搞明白。但是我在碼云平臺上我用的卻還是公鑰
參考網址:https://blog.csdn.net/u010387196/article/details/41266255
轉載于:https://www.cnblogs.com/qq917937712/p/11326142.html
總結
以上是生活随笔為你收集整理的一台电脑同时添加git和bitbucket两个网站的ssh key的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring实战(前言:Spring容器
- 下一篇: 基于python语言下的UI自动化测试框