git 同時(shí)配置 gitee github
1、
刪除C:\Users\dell\.ssh
目錄。
在任意目錄右擊——》Git Bash Here,打開Git Bash窗口,下方命令在Git Bash窗口輸入。
2、添加git全局范圍的用戶名和郵箱
git config --global user.email "609612189@qq.com"
git config --global user.name "609612189"
3、進(jìn)入C:\Users\dell\.ssh
目錄。
cd
cd ./.ssh
4、
# gitee 創(chuàng)建 ssh keys:
ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "609612189@qq.com"
# github 創(chuàng)建 ssh keys:
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa.github -C "609612189@qq.com"
C:\Users\dell\.ssh
下產(chǎn)生了id_rsa.gitee、id_rsa.gitee.pub、id_rsa.github、id_rsa.github.pub文件。
5、
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa.github
ssh-add ~/.ssh/id_rsa.gitee
6、在C:\Users\dell\.ssh
下創(chuàng)建文件config
,文件內(nèi)如下:
Host github.com
HostName github.com
Port 22
User git
IdentityFile ~/.ssh/id_rsa.github
Host gitee.com
HostName gitee.com
Port 22
User git
IdentityFile ~/.ssh/id_rsa.gitee
注意:2個(gè)端口都是22,github的端口不能是443。
7、
在GitHub的SSH公鑰,標(biāo)題填寫609612189,公鑰填寫id_rsa.github.pub 中的內(nèi)容。
在Gitee的SSH公鑰,標(biāo)題填寫609612189,公鑰填寫id_rsa.gitee.pub 中的內(nèi)容,Authentication Keys和Signing keys各添加1個(gè)。只添加Authentication Keys就可以連接到ssh -T git@github.com
了。
8、測(cè)試能否訪問。第1次訪問需要驗(yàn)證,直接輸入"yes"就好,驗(yàn)證完成會(huì)在know_hosts文件新增1行。如果沒有known_hosts文件,會(huì)在C:\Users\dell\.ssh
下產(chǎn)生known_hosts文件,再新增。
ssh -T git@gitee.com
ssh -T git@github.com
訪問成功如圖。
gitee和github的第1次訪問完成后,known_hosts文件內(nèi)容如下:
gitee.com,182.255.33.134 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMuEoYdx6to5oxR60IWj8uoe1aI0X1fKOHWOtLqTg1tsLT1iFwXV5JmFjU46EzeMBV/6EmI1uaRI6HiEPtPtJHE=
github.com,20.205.243.166 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg=
問題解決
1、
$ ssh -T git@gitee.com
kex_exchange_identification: read: Connection reset by peer
Connection reset by 180.76.198.77 port 22
報(bào)錯(cuò):Connection reset by peer。解決:不用學(xué)校的MUST-WiFi、dlink-206的wifi,要用手機(jī)卡1熱點(diǎn)。
連接gitee和連接github時(shí),用MUST-WiFi或者dlink-206的wifi都會(huì)報(bào)上方的錯(cuò)誤。
2、文章來源:http://www.zghlxwxcb.cn/news/detail-714135.html
$ ssh -T git@github.com
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 443
報(bào)錯(cuò):Connection closed by remote host。解決:把C:\Users\dell\.ssh\config
文件中,端口Port從443改成22。文章來源地址http://www.zghlxwxcb.cn/news/detail-714135.html
到了這里,關(guān)于git 同時(shí)配置 gitee github的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!