如何在Github设置SSH

157 阅读1分钟

关于 SSH

使用SSH协议你可以与服务器实现连接认证, 通过SSH,你可以不需要每次都提供用户名和密码就可以实现连接GitHub

一、 Checking for existing SSH keys

1、打开 Git Bash

2、输入 `ls -al ~/.ssh`
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

二、 Generating a new SSH key

1、打开 Git Bash

2、$ ssh-keygen -t ed25519 -C "your_email@example.com"
   注意:如果你的系统不支持ed25519算法,用如下方法
   $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

三、 Adding your SSH key to the ssh-agent

  1、打开https://github.com/settings/ssh/new
  
  2、复制粘贴SSH公钥

四、 测试SSH连接

  1、$  ssh -T git@github.com
  您可能会看到类似如下的警告:

The authenticity of host 'github.com (IP ADDRESS)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)?

  
  2、验证所看到消息中的指纹是否匹配, 如果是,则输入 `yes`:

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

五、参考文档

github身份验证

Gitee生成/添加SSH公钥