1. 下载git
官网 Git下载
2. 打开git bash
编辑
3. 全局设置
git config --global user.name "***" #名称
git config --global user.email ****@qq.com #邮箱
# 查看配置
git config --list
4. 设置ssh
# 设置github ssh
ssh-keygen -t ed25519 -C "joker" -f ~/.ssh/github
# 设置gitee ssh
ssh-keygen -t ed25519 -C "joker" -f ~/.ssh/gitee
# 设置gitlab ssh
ssh-keygen -t ed25519 -C "joker" -f ~/.ssh/gitlab
# 查看公钥,配置到github、gitee、gitlab
cat ~/.ssh/github.pub
5. github上配置ssh
查看公钥,然后复制
# 查看公钥
cat ~/.ssh/github.pub
编辑
然后输入命令验证是否配置成功
ssh -T git@github.com
编辑
6. 访问有问题的话,你可以配置一下config,自定义Host和ssh秘钥
编辑
这下面是我的配置,可以参考
vim ~/.ssh/config
Host github.com
User git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github
ServerAliveInterval 300
ServerAliveCountMax 10
Host gitlab.xxxx.com
User git
HostName gitlab.xxxx.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab
ServerAliveInterval 300
ServerAliveCountMax 10