1.配置名字和邮箱
--global 只需要配置一次 后续不需要继续配置
$ git config --global user.name "你github的用户名"
$ git config --global user.email "你github的邮箱"
2.生成密钥
$ ssh-keygen -t rsa -C "test@qq.com"
连续三个回车之后,不需要密码
获得两个文件 id_rea,id_rsa.pub

image.png
检查是否有ssh key
$ cd ~/.ssh
$ ls

image.png
验证添加密钥到ssh-agent
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
查看公钥内容
cat ~/.ssh/id_rsa.pub
3.添加密钥到github
登陆你的github帐户。
id_rsa.pub 的位置是在C:\Users\user\.ssh
点击你的头像,然后 Settings ->SSH and GPG keys -> New SSH key新建公钥title然后把id_rsa.pub里的内容全部复制粘贴到key里面。

image.png
验证ssh是否配置成功
$ ssh -T git@github.com
成功则返回
Hi 用户名!
You've successfully authenticated, but GitHub does not provide shell access.