Git 多用户配置
密钥
- 生成密钥
ssh-keygen -t rsa -C "EMail"s
(base) [15:55:07] [~] ❱❱❱ ssh-keygen -t rsa -C "youremail@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/snoer/.ssh/id_rsa):
- 在 github 设置中添加密钥
cat name_rsa.pub
config文件
- 找到
.ssh
文件夹, 添加config文件
cd /home/user_name/.ssh/
vim config
- 文件内容
Host aeron
HostName github.com
User aeron
IdentityFile ~/.ssh/aeron_rsa
Host snoer
HostName github.com
User snoer
IdentityFile ~/.ssh/snoer_rsa
- 参数说明
Host
主机别名, 可以自定义.
HostName
服务器真实地址
User
用户名, 随意.
IdentityFile
私钥文件路径
PreferredAuthentications
认证方式, 可不填写
- 配置检查
ssh -T git@aeron