ssh -key配置

打開Git,在Git命令行輸入cd? ~/.ssh檢查電腦本機(jī)是否有ssh key設(shè)置,.ssh是隱藏文件,一般在電腦C/用戶/Administrator下面就能夠找到。

1、進(jìn)入~路徑下,必須保證當(dāng)前路徑在~路徑下

在git命令行敲擊 ssh-keygen -t? rsa -C "xxx.@yyy.zzz" //建議寫自己真實(shí)有效的郵箱地址。

  然后命令行會(huì)出現(xiàn)如下代碼:

  Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa):? ?//此時(shí)我們什么都不需要操作,直接回車就好

  Enter passphrase (empty for no passphrase):? ? ? ? ? ? //此時(shí)要你輸入碼(可以為空,直接回車就好,也可以輸入你的密碼,這個(gè)密碼在你最后把本地資源推送到github上面的時(shí)候回會(huì)讓你填寫密碼,此時(shí)密碼隱藏,你輸入進(jìn)去是看不到的)

  Enter same passphrase again: //再次確認(rèn)密碼(如果你第一次有輸入密碼,這次就再輸一次,如果沒有直接回車就行了)

  Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa. //生成的密鑰

  Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub. //生成的公鑰

  The key fingerprint is:

  e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com

  *本機(jī)已完成ssh key設(shè)置,其存放路徑為:c:/Users/xxxx_000/.ssh/下。其中xxxx_000為你的用戶名。

2、添加ssh key 到Github上

首先登陸Github,點(diǎn)擊右上角的“▼”→Settings→SSH kyes→Add SSH key。

然后在打開c:/Users/xxxx_000/.ssh里面的id_rsa.pub文件,全選復(fù)制公鑰內(nèi)容

也可以在git bush中的命令行輸入cat ~/.ssh/id_rsa.pub,將得到公鑰

  Title自定義,將公鑰粘貼到GitHub中Add an SSH key的key輸入框,最后“Add Key“

 3、配置賬戶

  $ git config --global user.name “your_username” #設(shè)置用戶名

  $ git config --global user.email “your_registered_github_Email” #設(shè)置郵箱地址(建議用注冊(cè)giuhub的郵箱)

 4、測(cè)試ssh keys是否設(shè)置成功。

  ssh -T git@github.com

  The authenticity of host 'github.com (192.30.252.129)' can't be established.

  RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.

  Are you sure you want to continue connecting (yes/no)? yes #確認(rèn)你是否繼續(xù)聯(lián)系,輸入yes

  Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.

  Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa': #生成ssh kye是密碼為空則無此項(xiàng),若設(shè)置有密碼則有此項(xiàng)且,輸入生成ssh key時(shí)設(shè)置的密碼即可。

  Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出現(xiàn)此句話,說明設(shè)置成功。

最后編輯于
?著作權(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),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

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