Git項(xiàng)目對(duì)SSH的配置

今天提交代碼,push到GitHub上,突然出現(xiàn)這個(gè)問題。

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

大致意思是,密碼驗(yàn)證于2021年8月13日不再支持,也就是今天intellij不能再用密碼方式去提交代碼。請(qǐng)用使用personal access token替代。

這個(gè)去年年底就說了,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的源,也沒有這個(gè)問題)。

github配置SSH免密登錄

這里講的是Mac OS 操作。windows可以借鑒?

查看ssh目錄

ls-al~/.ssh

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

?-如果有配過,會(huì)列出:

?id_rsa (私鑰)——這個(gè)不能泄露

?id_rsa.pub(公鑰)

?-如果沒有配過,那么就進(jìn)入第二步

新建一個(gè)新的SSH KEY

ssh-keygen-t rsa-b4096-C"uestchan@sina.com"

接著會(huì)提示這個(gè)公鑰私鑰的保存路徑-建議直接回車就好(默認(rèn)目錄里)

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

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

配置好好,記住,你項(xiàng)目得使用 SSH clone

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

git修改遠(yuǎn)程倉庫地址

方法有三種:

1.修改命令

git remote origin set-url [url]

先刪后加

git remote rm origin

git remote add origin [url]

直接修改config文件

git文件夾,找到config,編輯,把就的項(xiàng)目地址替換成新的。

順手安利下?《git寶典—應(yīng)付日常工作使用足夠的指北手冊(cè)

關(guān)于github 建議讓換 Token的形勢(shì),操作如下

GitHub token?

打開自己的GitHub主頁,點(diǎn)擊自己的頭像找到Settings并進(jìn)入,在左邊目錄欄找到Personal access tokens,點(diǎn)擊Generate new token,按照步驟申請(qǐng)即可,過程簡單。Scopes(范圍)那里建議全選。

Token申請(qǐng)成功后,將Token復(fù)制到Token一欄中

操作路徑:

生成新的token就好。權(quán)限我是全部勾選上的。

Intellij IDEA 上Github賬號(hào)校驗(yàn)

配置Git路徑

打開Settings(File-->Settings) --> 在搜索欄內(nèi)輸入git,回車跳轉(zhuǎn)到Git配置頁面 --> 將git的運(yùn)行路徑填入Path to Git executable一欄(一般IDEA會(huì)自動(dòng)定位)

配置GitHub賬戶密碼

第一種方法可以選擇使用帳號(hào)密碼認(rèn)證(Password)

之前的老版是這樣的

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

現(xiàn)在新版本的,點(diǎn)擊密碼登錄,會(huì)自動(dòng)跳轉(zhuǎn)到登錄驗(yàn)證頁面,在驗(yàn)證頁面點(diǎn)擊確定(我的密碼是chrome記住的)。就自動(dòng)登錄

選擇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 協(xié)同 Git 與 GitHub 進(jìn)行開發(fā)使用http://www.itdecent.cn/p/ea1703adf5cc

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

Intellij IDEA 協(xié)同 Git 與 GitHub 進(jìn)行開發(fā)使用http://www.itdecent.cn/p/ea1703adf5cc

轉(zhuǎn)自:GitHub不再支持密碼驗(yàn)證解決方案:SSH免密與Token登錄配置 - 云+社區(qū) - 騰訊云 (tencent.com)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容