日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Windows 環境配置Github 的SSH key

作者:在奮斗的大道 更新時間: 2022-04-09 編程語言

今天需要將本機編寫的代碼提交至github 上,但是push 遠程分支提示如下錯誤信:

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

大致意思是:密碼驗證于2021年8月13日不再支持,請用使用 personal access token 替代。

GitHub 配置SSH key 詳細流程

1、先設置GitHub的user name和email

模板:

git config --global user.name "Git賬號"
git config --global user.email "Git郵箱"

實際操作

git config --global user.name "zhouzhiwengang@163.com" 
git config --global user.email "zhouzhiwengang@163.com"

2、使用Git Bash,生成一個新的SSH密鑰

打開 Git Bash,輸入如下命令,然后連續按三個回車即可:

模板:

ssh-keygen -t rsa -C "your_email@example.com"

實際操作:

ssh-keygen -t rsa -C "zhouzhiwengang@163.com"

?注:生成的SSH私鑰路徑 ssh-add /c/Users/Administrator/.ssh/id_rsa 后面要用到。

3、使用GitBash 將SSH私鑰添加到 ssh-agent

打開 Git Bash,在控制臺輸入如下指令,實現后臺啟動 ssh-agent

eval $(ssh-agent -s)

將SSH私鑰添加到 ssh-agent

ssh-add /c/Users/Administrator/.ssh/id_rsa

?4、將SSH公鑰添加到GitHub賬戶

1、打開 Git Bash,在控制臺輸入如下指令,實現復制SSH公鑰的完整內容

clip < /c/Users/Administrator/.ssh/id_rsa.pub

2、進入GitHub的設置頁面(登錄GitHub,在右上角)

?

?3、點擊左部側邊欄的 SSH keys 選項

4、點擊 NEW?SSH key 按鈕

?

5、在Title輸入框內,為你的新key取個名字,在Key輸入框內,粘貼前面復制好的公鑰內容,然后點擊 Add key 按鈕即可。

?

5、測試連接?

打開 Git Bash 輸入:

ssh -T git@github.com

將會看到如下提示:

?輸入yes后回車

如果提示中的用戶名是你的,說明SSH key已經配置成功。

本地項目提交方式由https 切換為SSH

git修改遠程倉庫地址

方法有三種:

  1. 1.修改命令
    • git remote origin set-url [url]
  2. 先刪后加
    • git remote rm origin
    • git remote add origin [url]
  3. 直接修改config文件
    • git文件夾,找到config,編輯,把就的項目地址替換成新的。

我選擇第二種方式。

?

原文鏈接:https://blog.csdn.net/zhouzhiwengang/article/details/122247683

欄目分類
最近更新