美文网首页
配置多个SSH KEY

配置多个SSH KEY

作者: hankin_h | 来源:发表于2023-10-30 18:08 被阅读0次
1.生成帐号 A 的 SSH Key,并在帐号 A 的 Gitee 设置页面添加 SSH 公钥:
ssh-keygen -t ed25519 -C "Gitee User A" -f ~/.ssh/gitee_user_a_ed25519
2.生成帐号 B 的 SSH-Key,并在帐号 B 的 Gitee 设置页面添加 SSH 公钥:
ssh-keygen -t ed25519 -C "Gitee User B" -f ~/.ssh/gitee_user_b_ed25519
3.创建或者修改文件 ~/.ssh/config,添加如下内容:
Host gt_a
    User git
    Hostname gitee.com
    Port 22
    IdentityFile ~/.ssh/gitee_user_a_ed25519
Host gt_b
    User git
    Hostname gitee.com
    Port 22
    IdentityFile ~/.ssh/gitee_user_b_ed25519
4.用 ssh 命令分别测试两个 SSH Key:
$ ssh -T gt_a
Hi Gitee User A! You've successfully authenticated, but GITEE.COM does not provide shell access.

$ ssh -T gt_b
Hi Gitee User B! You've successfully authenticated, but GITEE.COM does not provide shell access.

如果出现错误或者权限问题 chmod 700 ~/.ssh/, chmod 600 ~/.ssh/

5. 克隆项目

git@gitee.com 替换为 SSH 配置文件中对应的 Host,如原仓库 SSH 链接为:

git clone gt_a:owner/repo.git
git clone gt_b:owner/repo.git

相关文章

网友评论

      本文标题:配置多个SSH KEY

      本文链接:https://www.haomeiwen.com/subject/wmgbidtx.html