git推送遇到kex_exchange_identification:连接被远程主机关闭

删除本地~/.ssh目录
C:\Users\MiaoJw\.ssh
设置用户名
1 | git config --global user.name "Your Name" |
设置邮箱
1 | git config --global user.email "email@example.com" |
生成key
1 | ssh-keygen -t rsa -C "你的邮箱" |
打开
~/.ssh/id_rsa.pub(winC:\Users\name\.ssh\id_rsa.pub)并复制内容
转到GitHub SSH and GPG keys并创建新的SSH keys,粘贴内容并保存
试验:
1 | ssh -T git@github.com |
显示
Hi username! You've successfully authenticated, but GitHub does not provide shell access.即可!
如果还有Connection closed by 20.205.243.166 port 22则执行步骤2!
添加配置 config
创建
/修改~/.ssh/config文件,添加以下代码:
1 | Host github.com |
注意: config 如果该文件不存在,请自行创建文件!
可先创建
config.txt编辑内容保存后,删除.txt后缀即刻!
在测试下~
1 | ssh -T git@github.com |
引用站外地址
SSH Config 那些你所知道和不知道的事
https://deepzz.com/post/how-to-setup-ssh-config.html
评论
