多库下ssh密钥管理.
生成 ssh 密钥时,填入自定义密钥名字 例id_rsa.gerrit
ssh-keygen -t rsa -C "*******@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Work/.ssh/id_rsa): id_rsa.gerrit
一路enter
1.将id_rsa.gerrit.pub 公钥复制到客户端,cat ~/.ssh/id_rsa.gerrit.pub
2.在 ~/.ssh/ 路径下建立文件 config文件 touch ~/.ssh/config
3.vi ~/.ssh/config
输入
####内网的gerrit 地址
Host 172.16.16.222
### 没有hostname 就填ip
HostName 172.16.16.222### 私钥的路径
IdentityFile ~/.ssh/id_rsa.*****gitlab#### git config (--golabel) user.name 的值
User liulingdi### ssh端口,镜像搭建的gitlab,端口30187是由 gitlab 的ssh端口 22 映射出
Port 30187####多服务配置添加如上,公网的github,则填域名即可,port端口默认不用填写
Host github.com
HostName git

本文介绍了如何在多库环境下管理SSH密钥,特别是针对GitLab和Gerrit的容器化私有仓库。通过生成自定义名称的SSH密钥,配置~/.ssh/config文件,并为每个服务指定不同的IdentityFile和Host,实现不同服务的区分登录。成功配置后,可以使用ssh -T进行连接测试。
最低0.47元/天 解锁文章
826

被折叠的 条评论
为什么被折叠?



