一、设置用户名和邮箱
git config --global user.name "Your Name"
git config --global user.email "Your Email"
二、生成SSH密钥
ssh-keygen -t rsa -C "Your Email"
三、上传到Github
#复制输出的公钥内容
cat ~/.ssh/id_rsa.pub
- 登录Github
- 进入Settings
- SSH and GPG keys
- New SSH key
- 粘贴公钥内容
- Add SSH key
四、验证是否成功
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh -T git@github.com
#Hi XXX! You've successfully authenticated, but GitHub does not provide shell access.