github配置SSH免密登录

github配置SSH免密登录

github官方在2021年8月14日这一天,把终端push时的身份认证从password换成了token,就会遇到这个问题:remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

为了之后方便操作,直接配置了SSH免密登录,这里整理一下具体的步骤,很简单:

  1. 进入当前用户的home目录:
cd ~
  1. 删除已经存在的.ssh目录:
rm -r .ssh/
  1. 运行命令生成.ssh 密钥目录:
ssh-keygen -t rsa -C xxxx@gmail.com  # your github email address

一直enter确认就好了,完成后在ssh文件夹会生成一个公钥 id_rsa.pub 和一个私钥 id_rsa,我们只用公钥里的内容就行

  1. 查看公钥文件内容并复制所有内容
cat id_rsa.pub
  1. 登录 GitHub,点击用户头像 ->Settings -> SSHandGPG keys

image-20210928002852085

点击 New SSH key 创建新的 Secure Shell Key:

image-20210928003052255

  1. 复制之前公钥里的所有内容到 key 里:

image-20210928003159832

Title 没要求的话随便起就行,最好是备注一下哪个设备设置了SSH key,之后 Add SSH key 输入密码确认即可

完成上述操作后,在终端再次进行push等操作时github会直接跳过登录身份验证,直接连接到github服务器进行操作


github配置SSH免密登录
http://example.com/2021/09/28/github配置SSH免密登录/
Author
Zachary Deng
Posted on
September 28, 2021
Licensed under