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


今天提交代碼,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 -t rsa -b 4096 -C "uestchan@sina.com"

接着會提示這個公鑰私鑰的保存路徑-建議直接回車就好(默認目錄里)

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

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

WX20210814-184938@2x.png

配置好好,記住,你項目得使用 SSH clone

WX20210814-185202@2x.png

如果本地是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一欄中

操作路徑:

GitHub個人賬戶設置GitHub開發者中心

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

GitHub個人權限token設置

Intellij IDEA 上Github賬號校驗

配置Git路徑

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

配置GitHub賬戶密碼

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

intellij GitHub配置

之前的老板是這樣的

intellij 配置GitHub賬戶密碼

在Login一欄填入你GitHub的用戶名 --> Password那欄填入你GitHub的登錄密碼 

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

WX20210814-175230@2x.jpg

 

選擇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+Git https://www.cnblogs.com/yysbolg/p/8566389.html

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

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

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

 


免責聲明!

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



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