[TOC] #### 1. 問(wèn)題描述 --- 使用 git clone 拉取 github 倉(cāng)庫(kù)時(shí)報(bào)錯(cuò) ``` $ git clone git@github.com:shinyboys/test.git Cloning into 'test'... git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` ``` Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hos ``` 當(dāng)使用 git push 將本地代碼推送到遠(yuǎn)程倉(cāng)庫(kù)時(shí)也會(huì)報(bào)錯(cuò)  #### 2. 生成 SSH 公鑰 --- 這個(gè)應(yīng)該是很多 github 新手會(huì)遇到的問(wèn)題,原因就是當(dāng)前電腦沒(méi)有權(quán)限操作 github 倉(cāng)庫(kù)。解決辦法: 當(dāng)前電腦生成 ssh 密鑰文件,將 ssh 公鑰添加到 github 賬號(hào)上,然后就可以正常拉取、推送代碼了 執(zhí)行生成 ssh 密鑰的命令, 會(huì)有交互性操作,提示讓輸入密碼, 直接一路回車(chē)即可 ssh-keygen 用于生成、管理、轉(zhuǎn)換認(rèn)證秘鑰 參數(shù): -t,type 指定要?jiǎng)?chuàng)建的秘鑰類(lèi)型,可取值: rsa1(SSH-1)、rsa(SSH-2)、dsa(SSH-2) ``` ssh-keygen -t rsa ``` 查看生成的 SSH 公鑰 ``` cat ~/.ssh/id_rsa.pub ```  mac 系統(tǒng)生成 ssh 公鑰  #### 3. 在 github 上添加 SSH 公鑰 --- **前往個(gè)人中心設(shè)置 `Settings`**  **點(diǎn)擊左側(cè)欄目 `SSH and GPG keys`**  **將生成的 SSH 公鑰保存到 github 中, 建議標(biāo)題標(biāo)明 SSH 公鑰來(lái)源**  #### 4. 在 gitee 上添加 SSH 公鑰 ---  #### 5. 重新拉取項(xiàng)目 --- ``` git clone git@github.com:shinyboys/test.git ``` 