由于你的本地 Git 仓库和 GitHub 仓库之间的传输是通过SSH加密的,所以我们需要配置验证信息
ssh-keygen -t rsa -C "youremail@example.com"
your_email@youremail.com 改为你在 Github 上注册的邮箱,之后会要求确认路径和输入密码,一直回车即可
$ ssh-keygen -t rsa -C "your_email@youremail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/tianqixin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): # 直接回车
Enter same passphrase again: # 直接回车
Your identification has been saved in /Users/tianqixin/.ssh/id_rsa.
Your public key has been saved in /Users/tianqixin/.ssh/id_rsa.pub.
The key fingerprint is: # 直接回车
SHA256:MDKVidPTDXIQoJwoqUmI4LBAsg5XByBlrOEzkxrwARI 429240967@qq.com
The key's randomart image is:
+---[RSA 3072]----+
|E*+.+=**oo |
|%Oo+oo=o. . |
|%**.o.o. |
|OO. o o |
|+o+ S |
|. |
| |
| |
| |
+----[SHA256]-----+
成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的key
回到github,点进你的头像,进入Settings
验证成功
$ ssh -T git@github.com
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # 输入 yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Hi MonkeyCuratorofmemorial! You've successfully authenticated, but GitHub does not provide shell access. # 成功信息