1. 设置Git的user name和email:(如果是第一次的话)
点击(此处)折叠或打开
-
$ git config --global user.name "ue90"
- $ git config --global user.email "ylty@163.com"
点击(此处)折叠或打开
- vim ~/.gitconfig
点击(此处)折叠或打开
-
[user]
-
name = ue90
- email = ylty@163.com
点击(此处)折叠或打开
- ssh-keygen -t rsa -C "ylty@163.com"
点击(此处)折叠或打开
-
$ ssh-keygen -t rsa -C "ylty@163.com"
-
Generating public/private rsa key pair.
-
Enter file in which to save the key (/c/Users/lj/.ssh/id_rsa):
-
Created directory '/c/Users/lj/.ssh'.
-
Enter passphrase (empty for no passphrase):
-
Enter same passphrase again:
-
Your identification has been saved in /c/Users/lj/.ssh/id_rsa.
-
Your public key has been saved in /c/Users/lj/.ssh/id_rsa.pub.
-
The key fingerprint is:
-
SHA256:WHtPVMrdlDy6A0FeW7lIiRlmkL/m3ag007PLcrS4zEw ylty@163.com
-
The key's randomart image is:
-
+---[RSA 2048]----+
-
| .+=+.+.+|
-
| .+=.*oB |
-
| . ..*.+ +|
-
| o . + o . |
-
| . S . + . |
-
| . =.+ |
-
| oE=o= . |
-
| *++=o. |
-
| *=+. |
- +----[SHA256]-----+
3. 添加密钥到ssh-agent
确保 ssh-agent 是可用的。ssh-agent是一种控制用来保存公钥身份验证所使用的私钥的程序,其实ssh-agent就是一个密钥管理器,运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程。
点击(此处)折叠或打开
- #验证ssh-agent是否在运行
-
eval "$(ssh-agent -s)"
- Agent pid 12356
点击(此处)折叠或打开
- ssh-add ~/.ssh/id_rsa
4. 登陆git添加ssh key
登陆github官网:



按照以上步骤将~/.ssh/id_rsa.pub中的公钥信息添加到github中。
5. 测试
在git bash中输入以上命令,会看到
5. 测试
点击(此处)折叠或打开
- ssh -T git@github.com
点击(此处)折叠或打开
-
$ ssh -T git@github.com
-
The authenticity of host 'github.com (192.30.255.113)' can't be established.
-
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
-
Are you sure you want to continue connecting (yes/no)? yes
-
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of know n hosts.
- Hi ue90! You've successfully authenticated, but GitHub does not provide shell access.