1. 生成多个不同的sshkey秘钥
1.1 生成新的id_rsa公钥(个人)
ssh-keygen -t rsa -C "youremail@xxx.com" -f ~/.ssh/id_rsa
1.2 生成新的tc_pub公钥(公司)
ssh-keygen -t rsa -C "youremail@xxx.com" -f ~/.ssh/tc_pub
2. 在.ssh目录下新建一个config(无后缀文件)
(.ssh目录一般在C:/Users/xxx/.ssh目录)
# 个人account
Host github.com
HostName github.com
User CoderBruis
IdentityFile D:\MyConfiguration\TCLDUSER\.ssh\id_rsa
IdentitiesOnly yes
# 公司account
Host git.xxx.com
HostName git.xxx.com
User luohaiyang
IdentityFile D:\MyConfiguration\TCLDUSER\.ssh\tc_pub
IdentitiesOnly yes
3. 使用时不能设置全局username和email
取消设置全局的username和email
git config --global --unset user.name
git config --global --unset user.email
4. 在repo中使用不同的用户进行操作,进入repo目录后,需要先设置username和email,然后再进行其他操作
git config user.name CoderBruis
git config user.email "youemail"
然后查看该repo目录下,你的用户名和密码信息:
git config user.name
git config user.password
100. 命令总结
查看用户名 :git config user.name
查看密码: git config user.password
查看邮箱:git config user.email
测试ssh:ssh -T git@github.com