今年 8 月 13 日之后,如果你還用賬戶密碼來操作 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/<user>/<repo>/': The requested URL returned error: 403
解決方案就是使用訪問令牌(AccessToken),如果Git 客戶端提示你需要登錄 Github,賬戶輸入oauth2,密碼輸入你的令牌,
如果你已經用賬戶密碼登錄過了,在推送的時候,不會提示你登錄,而是直接報錯,這種情況就需要打開~/.git-credentials檔案,這個是Git客戶端儲存賬號密碼的地方,找到@github.com,把前面的用戶名密碼替換成oauth2:<token>,即大功告成,
注意,如果你的用戶名密碼在你倉庫的遠程 URL 里面,同樣需要用git remote set-url來替換掉,
其實所有 Git 服務端都可以這樣操作,這樣支持權限隔離和細粒度控制,避免一碼通密碼,更加安全,
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/294277.html
標籤:其他
下一篇:cgb2106-day16
