GitHub上传不了的解决 ssh: connect to host github.com port 22: Bad file number git did not exit cleanly (exit code 128)
问题情况
本来一直用的是github的客户端,结果现在上传的时候出问题了,去网站上看,新项目已经创建,但是代码却怎么都上传不上去。于是只好用命令行的方式解决。
Tortoisegit上是这样说的:
git.exe push -v --progress "xx" master:master
Pushing to git@github.com:xxx/xxxx.git
ssh: connect to host github.com port 22: Bad file number
fatal: Could not read from remote repository.
git did not exit cleanly (exit code 128)
gitbash上是这样说的
$ git status
On branch master
Your branch is based on 'origin/master', but the upstream is gone.
(use "git branch --unset-upstream" to fixup)
尝试解决
通过查询,发现在bash中自己没有授权key,于是按照教程,查询现有的密钥:
ls -al ~/.ssh
clip < ~/.ssh/id_rsa.pub
将现有的id_rsa加入到github网站上,并按照github的官网给的教程,将原有的id_rsa加入到本机的ssh:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
但是运行ssh -T git@github.com
命令还是显示ssh: connect to host github.com port 22: Bad file number
还是没有解决,然后在官网的常见问题中看到了BadFileNumber,有三种方法,1是用https,2是关于防火墙的,看起来比较麻烦,不想弄;3就是用ssh而非https
而我现在用的好像就是https啊,于是再试着用TortoiseGit试一下,还是不行。
那就用第三种方法吧,在~/.ssh/config
文件中增加,但是看看只有config file
而没有Config,于是就拷贝一个重命名为config
,把下面的代码粘贴:
Host github.com
Hostname ssh.github.com
Port 443
就能出现下面的成功授权提示啦~~~
The authenticity of host '[ssh.github.com]:443 ([192.30.253.123]:443)' can't be established.
RSA key fingerprint is .
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[ssh.github.com]:443,[192.30.253.123]:443' (RSA) to the list of known hosts.
Hi ! You've successfully authenticated, but GitHub does not provide shell access.
再去push看看,终于成功啦啦啦啦