Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights


第一次提交遇到這樣的情況,怎么回事呢,我在github上提交了ssh key 的啊。

排查先看看能不能解析,

1.先 ping https://github.com  

把ip添加到 host :    sudo vi /etc/hosts  (添加下面第三行)

127.0.0.1  localhost  localhost.localdomain  VM-0-6-ubuntu
127.0.1.1       TENCENT
192.30.255.113  github.com # 添加ip

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.30.255.113 github.com
~                         

2.如果不行的話看看自己有沒有輸入錯誤的創庫地址

查看配置

cat .git/config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@github:cuzz1/flask.git   # 錯誤的
        url = git@github.com:cuzz1/flask.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

3. 現在提交還出現

那就是github 上的ssh key 添加錯了,我們用ssh-keygen -t rsa -C "xxxx@163.com" 會生成在很多目錄下,比如root/.ssh、 /home/ubuntu/.ssh 都有ras_id.pub 

所以我們不能添加錯了。必須在 ~/.ssh目錄下  才有用,要是當前目錄,把  ~/.ssh/ras_id.pub 拷到github上就可以了。

現在提交就可以了。

 

感謝軍哥的幫忙 ,微信公眾號 Python之禪


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM