一匹耕、使用 git 客戶(hù)的生成公私鑰:id_rsa、id_rsa.pub
1荠雕、設(shè)置Git的user name和email
$ git config --global user.name "xxx"
$ git config --global user.email "xxx.mail@xxx.com"
2稳其、檢查是不是已經(jīng)存在密鑰(能進(jìn)去說(shuō)明已經(jīng)存在,就刪掉文件夾炸卑,重新創(chuàng)建):
cd ~/.ssh
3既鞠、生成 SSH 密鑰,打開(kāi)命令行終端輸入ssh-keygen -t rsa -C <your_email@example.com>
( 你的郵箱)盖文,連續(xù)點(diǎn)擊 Enter 鍵即可嘱蛋。
C:\Users\HASEE>ssh-keygen -t rsa -C "danhuanhong@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\HASEE/.ssh/id_rsa):// 推薦使用默認(rèn)地址
Created directory 'C:\Users\HASEE/.ssh'.
Enter passphrase (empty for no passphrase)://此處點(diǎn)擊 Enter 鍵即可,也可以填寫(xiě)密碼五续,填寫(xiě)密碼后每次使用 SSH 方式推送代碼時(shí)都會(huì)要求輸入密碼洒敏,由于這個(gè) Key 也不是用于軍事目的,所以也無(wú)需設(shè)置密碼疙驾。
Enter same passphrase again:
image.png
image.png
二凶伙、設(shè)置 SourceTree 的 SSH客戶(hù)端
1、配置SourceTree 的 SSH 客戶(hù)的為:OpenSSH
1.1 工具->選項(xiàng)
image.png
1.2 SSH客戶(hù)端配置它碎,選擇OpenSSH
image.png
三函荣、coding項(xiàng)目里面显押,部署公鑰>新建部署公鑰,把C:\Users\HASEE.ssh\id_rsa.pub的內(nèi)容復(fù)制到公鑰內(nèi)容中傻挂。
第一種:全局秘鑰,對(duì)賬號(hào)的所有項(xiàng)目有效
image.png
image.png
第二種:項(xiàng)目秘鑰,只對(duì)改項(xiàng)目有效
image.png
image.png
四乘碑、配置好SSH秘鑰后,拉取項(xiàng)目時(shí)踊谋,注意選擇SSH協(xié)議的鏈接蝉仇。
image.png
五、成功
image.png