1. 程式人生 > 實用技巧 >關於Git Please make sure you have the correct access rights問題解決

關於Git Please make sure you have the correct access rights問題解決

今天使用git clone命令報錯了,就是祕鑰過期了,重新生成新增到github伺服器就好了,步驟如下:

  • 刪除.ssh資料夾)下的known_hosts檔案,在C盤的使用者目錄下,我的路徑
C:\Users\LUMIN\.ssh
  • 開啟gitbash工具輸入命令
ssh-keygen -t rsa -C "username"

成功後返回以下確認資訊:

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

回車鍵繼續,因為以前有這個檔案儲存了祕鑰資訊,所以會返回覆蓋的確認資訊如下:

/c/Users/LUMIN/.ssh/id_rsa already exists.
Overwrite (y/n)? 

輸入y,回車繼續,因為以前沒有儲存地址,返回以下資訊:

Enter passphrase (empty for no passphrase):

再次回車,返回再次確認資訊:

Enter same passphrase again:

回車確認,返回以下資訊,表示已生成SSH Key

Your identification has been saved in /c/Users/LUMIN/.ssh/id_rsa.
Your public key has been saved in /c/Users/LUMIN/.ssh/id_rsa.pub.

找到自動在.ssh資料夾下的id_rsa.pub,把內容複製到github的SSH Key中

最後輸入ssh -T [email protected],測試是否成功,輸入yes,繼續連線:

The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

以下資訊成功

Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi luminqiang! You've successfully authenticated, but GitHub does not provide shell access.