多个ssh密钥对处理

多个.ssh密钥对时
添加密钥wgc
$ ssh-keygen -t rsa -C "admin1@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa_wgc
添加密钥mlj
$ ssh-keygen -t rsa -C "admin2@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa_mlj

密钥添加到SSH agent中
因为默认只读取id_rsa,为了让SSH识别新的私钥,需将其添加到SSH agent中:
$ ssh-agent bash
$ ssh-add ~/.ssh/id_rsa_wgc
$ ssh-add ~/.ssh/id_rsa_mlj

修改(新建)config文件
在~/.ssh目录下找到config文件
Host wgc
  HostName gitee.com
  User git
  IdentityFile C:\Users\Administrator\.ssh\id_rsa_wgc

Host mlj
  HostName gitee.com
  User git
  IdentityFile C:\Users\Administrator\.ssh\id_rsa_mlj

添加公钥到平台:  

测试
$ ssh -T git@gitee.com
$ ssh -T wgc
$ ssh -T mlj
若返回:
Welcome to Gitee.com, yourname!
表示成功!

TortoiseGit配置:
设置->网络->SSH客户端  C:\Program Files\Git\usr\bin\ssh.exe

TortoiseGit添加URL时有点不一样

git@gitee.com就用wgc和mlj代替,因为要对应不同的key!!!

 

 

转载于:https://my.oschina.net/wgc2010/blog/1616686

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值