git 推送到 github時報許可權禁止
阿新 • • 發佈:2018-11-03
推送流程:
1、建立遠端關聯,在需要推送的倉庫目錄下關聯github
git remote add origin [email protected]:username/learngit.git
2、開始推送
git push -u origin master
在這裡推送是報錯了,查看了之後是由於沒有公鑰和私鑰,將本地的推送到遠端時,遠端伺服器需要持有你本地的公鑰,所以,首先要在本地生成公鑰和私鑰,然後把公鑰發給遠端伺服器。
The authenticity of host 'github.com (13.229.188.59)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
3、在本地生成公鑰和私鑰,檢視下本地的ssh金鑰,這裡的公私鑰是我連線我的郵箱生成的。郵箱是我github賬戶關聯的郵箱。執行該命令一直回車即可。由於我之前執行過一次,所以這次我選擇了overwrite覆蓋。
4、生成後,將id_rsa.pub裡面的key新增到github裡面。在github介面,點選右上角里面的setting-》SSH and GPG keys-》New SSH key,然後進行新增。
5、新增完key後,重新push一遍。成功。
6、推送後本地和遠端的目錄情況。