git 同时配置 gitee github

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

git 同时配置 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、进入C:\Users\dell\.ssh目录。

cd
cd ./.ssh

4、

# gitee 创建 ssh keys
ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "609612189@qq.com"
# github 创建 ssh keys
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa.github -C "609612189@qq.com"

C:\Users\dell\.ssh下产生了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下创建文件config文件内如下

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个端口都是22github的端口不能是443。

7、
GitHub的SSH公钥标题填写609612189公钥填写id_rsa.github.pub 中的内容。
Gitee的SSH公钥标题填写609612189公钥填写id_rsa.gitee.pub 中的内容Authentication Keys和Signing keys各添加1个。只添加Authentication Keys就可以连接到ssh -T git@github.com了。

8、测试能否访问。第1次访问需要验证直接输入"yes"就好验证完成会在know_hosts文件新增1行。如果没有known_hosts文件会在C:\Users\dell\.ssh下产生known_hosts文件再新增。

ssh -T git@gitee.com
ssh -T git@github.com

访问成功如图。
在这里插入图片描述
gitee和github的第1次访问完成后known_hosts文件内容如下

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

报错Connection reset by peer。解决不用学校的MUST-WiFi、dlink-206的wifi要用手机卡1热点。
连接gitee和连接github时用MUST-WiFi或者dlink-206的wifi都会报上方的错误。

2、

$ ssh -T git@github.com
kex_exchange_identification: Connection closed by remote host
Connection closed by 20.205.243.166 port 443

报错Connection closed by remote host。解决把C:\Users\dell\.ssh\config文件中端口Port从443改成22。

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6