1、如果配置一个ssh-key,直接执行如下命令:
$ssh-****** -t rsa -C "[email protected]",然后在系统盘所在用户文件夹下会生
成一个.ssh文件夹。在文件夹中会生成两个文件,id_rsa和id_rsa.pub
然后在github或者gitLab中配置上ssh
git 配置多个ssh
git 配置多个ssh
git 配置多个ssh
打开git,执行代码测试:ssh -T [email protected],测试时会提示是否加入可信任的
host,选择yes

2、如果需要配置多个ssh-key:
①执行下面的命令
$ssh-****** -t rsa -f ~/.ssh/github_rsa -C "[email protected]"
-f后面是手动指定生成的秘钥文件名和所在文件夹,如果没有指定,每次生成的新秘
钥都会覆盖原有的。

②在.ssh文件夹中创建config,并写入一下内容
#github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa

#gitlab
Host 192.168.6.21
HostName 192.168.6.21
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_rsa

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2021-12-14
  • 2022-02-06
  • 2022-02-07
  • 2021-05-24
  • 2023-02-16
猜你喜欢
  • 2021-08-09
  • 2021-10-30
  • 2021-08-27
  • 2021-06-19
  • 2021-05-29
  • 2021-12-31
  • 2022-02-17
相关资源
相似解决方案