問題情況
本來一直用的是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看看,終於成功啦啦啦啦