以前由於好久沒有使用github來託管代碼了,加上公司內部搭建了gitlab服務器,因此從未沒有嘗試過配置不一樣的帳戶來推送更新git
問題比較蛋疼的是在未推送以前,github上新建了一個倉庫,而後準備clone下來。因此就臨時生成了一個ssh-key(由於更換過電腦,因此從新配置了),可是clone的時候被服務器拒絕了github
Cloning into 'learngit'...shell
The authenticity of host 'github.com (xxx.xxx.xxx.xxx)' can't be established.服務器
RSA key fingerprint is 16:27:xxx:xxx:xxxx.ssh
Are you sure you want to continue connecting (yes/no)? ide
Host key verification failed.gitlab
fatal: Could not read from remote repository.測試
尼瑪,這是怎麼回事,我又從新生成了一遍ssh-key,照樣報錯,查看了官方的issue,用ssh -T測試了一把google
ssh -T git@github.com Permission denied (publickey)
的確被拒絕了。哪裏配置不對嗎?spa
OMG,沒有配置倉庫的gitconfig?好,那我配置!尼瑪,依然被拒絕了。腫麼回事,乾淨百度/google下
擦!原來要針對github的訪問作一個配置。。ok
vi ~/.ssh/config // 粘貼一下內容 Host github.com User git Port 22 IdentityFile ~/.ssh/id_rsa_github
ok! 妥妥的。再測試一把
bird-mac:bird$ test bird-jarvis$ ssh -T git@github.com
Hi bird! You've successfully authenticated, but GitHub does not provide shell access.
個人公鑰:ssh-keygen -t rsa -f id_rsa_github -C "key for github"