简单的说用两对ssh密钥来连接多个github账户,有的同学问:用一对连接多个账户行吗?答案是不行,因为密钥和你的账户邮箱关联了。

1、生成密钥。

sshkey -t rsa -b 4096 -C "your_email_1@host.com"

2、设置密钥对的名字,在第一步中,系统会提示如下:

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/your_name

注意必须是完整路径,系统会生成your_name和your_name.pub两个文件。

3、将密钥添加到ssh-agent当中。

#在后台启动ssh-agent,系统回显pid

eval  "$(ssh-agent  -s)"

ssh-add ~/.ssh/your_name

4、复制公钥到github账户的设置选项中,然后保存。

也就是your_name.pub

5、测试一下。

ssh -T git@github.com

如果系统提示如下,说明成功安装第一个了。

Hi your_name! You've successfully authenticated, but GitHub does not provide shell access.

6、重复第1-5步,第二个账户安装好了,而且这两个都可以访问。

相关文章:

  • 2021-12-26
  • 2021-07-09
  • 2021-09-28
  • 2021-11-30
  • 2022-02-08
  • 2021-12-12
  • 2021-04-16
猜你喜欢
  • 2022-12-23
  • 2021-10-05
  • 2021-09-01
  • 2022-01-09
  • 2022-12-23
  • 2021-10-21
  • 2021-10-18
相关资源
相似解决方案