1、在本地找到,~/.ssh 文件夹

2、执行 ssh-keygen -t rsa -C "Winseek" -f "id-rsa-github"

3、生成了id-rsa-github和id-rsa-github.pub,copy id-rsa-github.pub

4、登录github,在setting里找到,SSH and GPG keys,新增ssh key 粘贴进去

5、在本地执行,ssh-add ~/.ssh id-rsa-githb

6、测试是否成功 ssh -T git@github.com

注意:

使用ssh-add 会存在一个坑,就是下次再重启电脑时,发现git连接不上了,这时需要配置config了

vi config

Host github.com

 User git

 Hostname github.com

 PreferredAuthentications publickey

 IdentityFile ~/.ssh/id-rsa-github

 

Host gitlab.com

 User git

 Hostname gitlab.com

 PreferredAuthentications publickey

 IdentityFile ~/.ssh/id-rsa-gitlab

相关文章:

  • 2022-12-23
  • 2021-08-09
  • 2021-12-22
  • 2022-12-23
  • 2021-06-22
  • 2021-07-17
  • 2021-07-11
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2022-12-23
  • 2021-05-31
  • 2021-09-23
  • 2022-12-23
  • 2022-01-06
  • 2021-10-20
相关资源
相似解决方案