win git配置 github和gitee
1. 首先使用git生成两个 SSH Key
git config --global user.name "Your Name" //配置全局名字
git config --global user.email "email@example.com" //配置全局邮箱
例如:
git config --global user.name "***" //配置全局名字
git config --global user.email "***@qq.com" //配置全局邮箱
1. ssh-keygen -t rsa -C "你的github邮箱@qq.com" -f "id_rsa_github"
2. ssh-keygen -t rsa -C "你的gitee邮箱@qq.com" -f "id_rsa_gitee"
例如:
1. ssh-keygen -t rsa -C "***@qq.com" -f "id_rsa_github"
2. ssh-keygen -t rsa -C "***@qq.com" -f "id_rsa_gitee"
- 生成两个文件和别对于公钥和私钥,输入命令后一直回车即可
2. 配置github
- 首先登陆githubgithub.com/login
- 把公钥粘贴到ssh公钥里
3. 大工告成
- config配置如下:
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
- 验证如下:
ssh -T git@gitee.com
ssh -T git@github.com
mac 相关
cat /etc/ssh/ssh_config
ssh-add ~/.ssh/id_rsa_github
ssh-add ~/.ssh/id_rsa_gitee
ssh -v git@github.com