- Git配置
打開Git Bash
配置你的用戶名和郵箱
git config --global user.name “zhangsan”
git config --global user.email “zhangsan@xxxx.com” - 生成SSH key
ssh-keygen -t rsa -C “zhangsan@xxxx.com” - 獲取SSH Key
根據(jù)命令行提示,獲取以ssh-rsa的字符串(包括ssh-rsa)
按鍵”回車鍵“ 生成了SSH Key(密鑰)如下圖所示: - SSH key 生成的路徑如下圖所示:TXT格式打開進(jìn)行全選復(fù)制內(nèi)容
- 登錄github賬號(hào)添加SSH Key 如下圖所示:
- 將第四步復(fù)制的內(nèi)容進(jìn)行粘貼到如下圖所示里面:
- 檢測是否配置(SSH Key) 成功 輸入本地git-bash輸入命令:ssh -T git@github.com 成功則如下圖所示:
Mac 生成SSH Key 請(qǐng)參閱:一、密鑰生成
于是乎,找了下 mac 系統(tǒng)如何生成秘鑰的方法,記錄在此:
【Step 1】 打開終端,輸入 cd ~/.ssh,檢查是否已經(jīng)存在了SSH密鑰。如果你看到類似id_rsa.pub的文件,說明你已經(jīng)有了一對(duì)公鑰和私鑰,可以跳過第 2 步和第 3 步。
【Step 2】 在終端輸入ssh-keygen -t rsa -C “你的郵箱地址” ,生成新的SSH密鑰。你可以直接按回車鍵使用默認(rèn)的文件路徑和空密碼,也可以自己設(shè)置。
【Step 3】 在終端輸入ssh-add ~/.ssh/id_rsa,添加SSH密鑰到 ssh-agent。如果你之前設(shè)置了密碼,這里需要再次輸入。
【Step 4】 在終端輸入vim ~/.ssh/id_rsa.pub,查看并復(fù)制你的公鑰內(nèi)容。你可以把公鑰添加到文章來源:http://www.zghlxwxcb.cn/news/detail-859633.html
原文鏈接:https://blog.csdn.net/w605283073/article/details/130038455
【5】如果在clone時(shí)報(bào):
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
執(zhí)行:rm -rf ~/.ssh/known_hosts
【6】如果在clone時(shí)報(bào):確定要繼續(xù)連接嗎(是/否/[指紋])?
ssh -o UserKnownHostsFile=$HOME/.config/ssh/known_hosts git@github.com (你的git clone 網(wǎng)址)
請(qǐng)參閱:https://www.null123.com/question/detail-2584509.html文章來源地址http://www.zghlxwxcb.cn/news/detail-859633.html
到了這里,關(guān)于Git 本地配置SSH Key(密鑰)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!