1. 程式人生 > 其它 >GitHub不再支援密碼驗證解決方案:SSH免密與Token登入配置

GitHub不再支援密碼驗證解決方案:SSH免密與Token登入配置

GitHub在本地可以用使用者密碼校驗,也可以是person token校驗,還可以用ssh。但是Support for password authentication was removed on August 13, 2021 Please use a personal access token instead 個人推薦還是SSH 免登方式使用較好

今天提交程式碼,push到GitHub上,突然出現這個問題。

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

fatal: unable to access 'https://github.com/zhoulujun/algorithm.git/': The requested URL returned error: 403

官方的解釋:https://github.blog/changelog/2021-08-12-git-password-authentication-is-shutting-down/

As previously announced, starting on August 13, 2021, at 09:00 PST, we will no longer accept account passwords when authenticating Git operations on GitHub.com. Instead, token-based authentication (for example, personal access, OAuth, SSH Key, or GitHub App installation token) will be required for all authenticated Git operations.

Please refer to this blog post for instructions on what you need to do to continue using git operations securely.

Removal

  • August 13, 2021, at 09:00 PST

大致意思是,密碼驗證於2021年8月13日不再支援,也就是今天intellij不能再用密碼方式去提交程式碼。請用使用personal access token替代。

這個去年年底就說了,https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

In July 2020, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations.Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

自己鼓搗了一遍 Token,煩人的很。還是覺得直接ssh 的方式操作git就好(之前是ssh的源,也沒有這個問題)。

github配置SSH免密登入

這裡講的是Mac OS 操作。windows可以借鑑

檢視ssh目錄

ls-al~/.ssh

Mac OS目錄~/.ssh,windows目錄是: Users/uestc/.ssh/id_rsa

-如果有配過,會列出:

  • id_rsa (私鑰)——這個不能洩露

  • id_rsa.pub(公鑰)

-如果沒有配過,那麼就進入第二步

新建一個新的SSH KEY

ssh-keygen-trsa-b4096-C"[email protected]"

接著會提示這個公鑰私鑰的儲存路徑-建議直接回車就好(預設目錄裡)

接著提示輸入私鑰密碼passphrase - 如果不想使用私鑰登入的話,私鑰密碼為空,直接回車

生成成功後,把id_rsa.pub 拷貝到 github 新建的 SSH keys 中

配置好好,記住,你專案得使用 SSH clone

如果本地是https 源,那麼就修改git 倉庫地址

git修改遠端倉庫地址

方法有三種:

  1. 1.修改命令

    • git remote origin set-url [url]

  2. 先刪後加

    • git remote rm origin

    • git remote add origin [url]

  3. 直接修改config檔案

    • git資料夾,找到config,編輯,把就的專案地址替換成新的。

順手安利下《git寶典—應付日常工作使用足夠的指北手冊

關於github 建議讓換 Token的形勢,操作如下

GitHub token

開啟自己的GitHub主頁,點選自己的頭像找到Settings並進入,在左邊目錄欄找到Personal access tokens,點選Generate new token,按照步驟申請即可,過程簡單。Scopes(範圍)那裡建議全選。

Token申請成功後,將Token複製到Token一欄中

操作路徑:

生成新的token就好。許可權我是全部勾選上的。

Intellij IDEA 上Github賬號校驗

配置Git路徑

開啟Settings(File-->Settings) --> 在搜尋欄內輸入git,回車跳轉到Git配置頁面 --> 將git的執行路徑填入Path to Git executable一欄(一般IDEA會自動定位)

配置GitHub賬戶密碼

第一種方法可以選擇使用帳號密碼認證(Password)

之前的老闆是這樣的

在Login一欄填入你GitHub的使用者名稱 --> Password那欄填入你GitHub的登入密碼

現在新版本的,點選密碼登入,會自動跳轉到登入驗證頁面,在驗證頁面點選確定(我的密碼是chrome記住的)。就自動登入

選擇log width token,填入token就好

參考文章:

github配置SSH免密登入https://blog.csdn.net/qq_38163309/article/details/105335097

GIT免密登入神器 SSH KEY配置詳解https://blog.csdn.net/w15321271041/article/details/80535135

Intellij IDEA 使用GitHub+Githttps://www.cnblogs.com/yysbolg/p/8566389.html

Intellij IDEA 協同 Git 與 GitHub 進行開發使用https://www.jianshu.com/p/ea1703adf5cc

Github 生成token的方法 — IDEA 拉程式碼或push失敗需要從新校驗Tokenhttps://blog.csdn.net/SR02020/article/details/106882205

Intellij IDEA 協同 Git 與 GitHub 進行開發使用https://www.jianshu.com/p/ea1703adf5cc