全站文章索引 📚📚📚

展開全部 | 收合全部

全站文章索引 📚📚📚

展開全部 | 收合全部

【Git】問題解決:remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/20XX-XX-XX-token-authentication-requirements-for-git-operations/ for more information.

問題描述

當我們想要使用 git 時,出現以下類似訊息 (日期可能不同) 的解決方法。

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.

問題成因

原因是 github 從 August 13, 2021 之後,
對於 git 相關的存取已不再支援 password,須改用token方式進行。

可參考 github 的 blog

2021/8/27 更新:新的解法

舊的解法並不能一次就治好,必須還要每次都重新產生 token,
這次為了安全性問題,反而造成了一些額外的麻煩啊…

因此現在找到了一個新的方法,可以直接避免後續需要重新產生 token 的問題。

我們前面的步驟一樣要像舊的解法去產生 token,
差別在最後一步,我們不把 token 當作密碼輸入,
我們新增一個 remote,包含著我們的 token,

雖然快速,但快的代價相對的就是容易有資安問題,請自行注意。

新增 git remote

git remote set-url origin https://<githubtoken>@github.com/<username>/<repositoryname>.git

範例:

git remote set-url origin https://[email protected]/howarder3/test_repo.git

解法引用自:

舊的解法

這個算是 git 為了安全性所新增的功能,
讓我們的 git 過一段時間之後憑證就會自動過期
(也就是說,隔一段時間就會沒辦法直接與遠端同步)

我們可以去 github 的頁面進行相關設定

step 1. 去個人頁面的 Settings

step 2. 找到左側的 Developer settings

step 3. 點選 Personal access tokens

step 4. 選擇 Generate new token

step 5. 設定 token 過期的時間、允許的範圍

step 6. 得到對應的 token

上面 step 5 後,我們會得到一串類似以下的 token

ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

之後我們回到我們的 terminal,
這次我們一樣輸入帳號,
並將「密碼改為上面那串 token」,問題即可解決。

Reference

Howard Weng
Howard Weng

我是 Howard Weng,很多人叫我嗡嗡。這個網站放了我的各種筆記。希望這些筆記也能順便幫助到有需要的人們!如果文章有幫助到你的話,歡迎幫我點讚哦!
另外,因為定位是「個人的隨手筆記」,有些文章內容「⚠️可能我理解有誤⚠️」或「🥱只寫到一半😴」,如果有發現這樣的情況,歡迎在該文章的最下面留言提醒我!我會儘快修正或補上!感謝大家的建議與幫忙,讓網站能變得更好🙏

文章: 817

★留個言吧!內容有誤或想要補充也歡迎與我討論!