目标
- 整理GIT(ssh)支持多用户管理
配置本地github账户
- 创建rsa密钥
cd ~/.ssh
ssh-keygen -t rsa -C "xxxx@email.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Dell/.ssh/id_rsa): /c/Users/Dell/.ssh/local/id_rsa_local - 复制密钥到github ssh中
配置私服gitlab账户
- 创建rsa密钥
cd ~/.ssh
ssh-keygen -t rsa -C "xxxx@email.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Dell/.ssh/id_rsa): /c/Users/Dell/.ssh/ruoze/id_rsa_ruoze - 复制密钥到github ssh中
配置config
- 在.ssh目录下创建config文件,*注意仅仅是 config *
- 在配置文件中添加如下配置说明:
# github 针对github的配置
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/local/id_rsa
# ruoze
Host git.ruozedata.com
HostName git.ruozedata.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/ruoze/id_rsa_ruoze
Host:包含端口,如果端口是80就不显示,即git@host
@ 后面的部分
HostName:不包含端口,此处指定Host对应的具体域名
User:说明该配置的用户是git,即git@hostname
@ 前面的部分
Port:git端口
测试
ssh -T git@host |