git 同时配置 gitee github

git 同时配置 gitee github

1、

删除C:\Users\dell\.ssh目录。

在任意目录右击------》Git Bash Here,打开Git Bash窗口,下方命令在Git Bash窗口输入。

2、添加git全局范围的用户名和邮箱

bash 复制代码
git config --global user.email "[email protected]"
git config --global user.name "609612189"

3、进入C:\Users\dell\.ssh目录。

bash 复制代码
cd
cd ./.ssh

4、

bash 复制代码
# gitee 创建 ssh keys:
ssh-keygen -t rsa -f ~/.ssh/id_rsa.gitee -C "[email protected]"
# github 创建 ssh keys:
ssh-keygen -t ed25519 -f ~/.ssh/id_rsa.github -C "[email protected]"

C:\Users\dell\.ssh下产生了id_rsa.gitee、id_rsa.gitee.pub、id_rsa.github、id_rsa.github.pub文件。

5、

bash 复制代码
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个端口都是22,github的端口不能是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 [email protected]了。

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

bash 复制代码
ssh -T [email protected]
ssh -T [email protected]

访问成功如图。

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、

bash 复制代码
$ ssh -T [email protected]
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、

bash 复制代码
$ ssh -T [email protected]
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。

相关推荐
饼干ovo2 小时前
shell编程
java·git·github
HelloGitHub4 小时前
3 个超火的开源项目「GitHub 热点速览」
开源·github
JinSo5 小时前
create-easy-editor —— 快速搭建你的可视化编辑器
前端·前端框架·github
bubiyoushang8889 小时前
解决 Git 访问 GitHub 时的 SSL 错误
git·github·ssl
tonngw11 小时前
【Mac 从 0 到 1 保姆级配置教程 16】- Docker 快速安装配置、常用命令以及实际项目演示
macos·docker·容器·开源·github·docker desktop·orbstack
海码00713 小时前
【版本控制】Git 和 GitHub 入门教程
git·github
网硕互联的小客服16 小时前
503 Service Unavailable:服务器暂时无法处理请求,可能是超载或维护中如何处理?
服务器·git·github
abcnull18 小时前
github开源协议选择
git·github·开源协议
安庆平.Я20 小时前
git互联GitHub 使用教程
git·github
掘金安东尼1 天前
字节-Trae、阿里-通义灵码、腾讯-CodeBuddy,为什么都在“卷”AI编码?
面试·llm·github