1 前提:已安裝Git
2 檢查SSH公鑰
切換到提交倉庫
image.png
cd ~/.ssh
看看存不存在.ssh,如果存在的話援雇,掠過下一步裕循;不存在的請(qǐng)看下一步
3 生成SSH公鑰
$ ssh-keygen -t rsa -C "17xxxxx30@qq.com"
# Creates a new ssh key using the provided email Generating public/private rsa key pair.
Enter file in which to save the key (/home/you/.ssh/id_rsa):
按回車,現(xiàn)在你可以看到娇昙,在自己的目錄下尺迂,有一個(gè).ssh目錄,說明成功了
3.1 輸入github密碼
Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
這個(gè)時(shí)候輸入你在github上設(shè)置的密碼。
image.png
3.2 然后在.ssh中可以看到
image.png
4 添加SSH公鑰到github
打開github噪裕,找到賬戶里面添加SSH蹲盘,把id_rsa.pub內(nèi)容復(fù)制到key里面。
image.png
粘貼到自己的公鑰列表中
image.png
5 測(cè)試是否生效
使用下面的命令測(cè)試
ssh -T git@github.com
當(dāng)你看到這些內(nèi)容放入時(shí)候膳音,直接yes
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?
Hi username!
You've successfully authenticated, but GitHub does not provide shell access.
看到這個(gè)內(nèi)容放入時(shí)候召衔,說明就成功了。