1. 程式人生 > >git "Could not read from remote repository.Please make sure you have the correct access rights."解決方案

git "Could not read from remote repository.Please make sure you have the correct access rights."解決方案

tpc 覆蓋 com 設置 _id pub ould ack ref

我們在使用git clone 或其他命令的時候,有時候會遇到這類問題,如圖:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.

出現這個問題是因為沒有在github賬號添加SSH key

解決方法如下:

1.在終端輸入。

ssh-keygen -t rsa -C "username" (註:username為你git上的用戶名)

上面的username(一般是管理員分配的,自己創建的應該沒權限)

如果執行成功。返回

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/username/.ssh/id_rsa):

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):

首先,說明一下,這裏的username是你電腦上的用戶名

然後,在這裏就是設置存儲地址了.我們直接按回車(一直按回車就行),會出現一下兩種情況的一種:

(1)如果正常運行的話,會出現

Enter passphrase (empty for no passphrase):

然後我們直接回車

(2)有的時候我們可能會出現

/Users/your username/.ssh/id_rsa already exists.

Overwrite (y/n)?

這說明你已經設置了存儲地址,我們輸入“y”覆蓋

Overwrite (y/n)? y

回車

上面的任意兩種情況之後,會出現

Enter same passphrase again:

再次回車,這時候你會看見:

Your identification has been saved in /Users/username/.ssh/id_rsa.

Your public key has been saved in /Users/username/.ssh/id_rsa.pub.

The key fingerprint is:

58:42:8b:58:ad:4b:b5:b9:6d:79:bf:8c:f9:e2:2b:ed username

The key‘s randomart image is:

+--[ RSA 2048]----+

| ... |

| o oo. |

| . .ooo. |

| o o+ |

| . ..oS. |

| . . + . |

| . o . |

| . o+. |

| +E++. |

+-----------------+

這說明SSH key就已經生成了。文件目錄就是:/Users/username/.ssh/id_rsa.pub.

我們執行cat命令查看文件的內容:

cat /User/username/.ssh/id_rsa.pub

這時候會看見:

ssh-rsa AAAAB3NzaC1yc2。。。。。。。。。

後面的內容我省略了

(說明:ssh-rsa 後面的內容這就是你的SSH keys)

把顯示出來的SSH keys直接添加到github賬戶設置裏邊的SSH keys(全部的秘鑰包括ssh-rsa以及後面所有的)

最後再執行git clone命令就可以了

git "Could not read from remote repository.Please make sure you have the correct access rights."解決方案