配置ssh-key连接github

GitHub 通过在 2022 年 3 月 15 日删除旧的、不安全的密钥类型来提高安全性。

具体内容参考如下链接
https://docs.github.com/zh/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

mac配置

shell 复制代码
ssh-keygen -t ed25519 -C "devops@game.vip"

vim ~/.ssh/config
Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

生成后将公钥添加至个人github账号里

shell 复制代码
cat ~/.ssh/id_ed25519.pub 

文章中有个关键提示,我mac没有给秘钥配置密码 但没有报错,ubuntu去掉了 不然那会报错

如果你选择不向密钥添加密码,应该省略 UseKeychain 行。

如果看到 Bad configuration option: usekeychain 错误,请在配置的 Host *.github.com 部分添加额外的一行。

ubuntu配置

shell 复制代码
# 生成公钥,这里邮箱随用于区分公钥所属账号
ssh-keygen -t ed25519 -C "devops@game.vip"

# 配置
Host github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519
相关推荐
晨非辰2 小时前
Linux权限管理速成:umask掩码/file透视/粘滞位防护15分钟精通,掌握权限减法与安全协作模型
linux·运维·服务器·c++·人工智能·后端
夜颂春秋3 小时前
jmeter做压力测试
linux·运维·服务器·压力测试
CoderJia程序员甲9 小时前
GitHub 热榜项目 - 日榜(2026-01-27)
github
绾樘9 小时前
RHCE--基于Nginx的Web服务器配置
运维·服务器·nginx
打工的小王10 小时前
docker(三)具体项目的部署
运维·docker·容器
一叶星殇12 小时前
.NET WebAPI:用 Nginx 还是 IIS 更好
运维·nginx·.net
LEEE@FPGA14 小时前
zynq 是不是有了设备树,再linux中不需要编写驱动也能控制
linux·运维·单片机
Trank-Lw14 小时前
Docker Devcontainer 管理命令
运维·docker·容器
RisunJan14 小时前
Linux命令-less(分页查看器)
linux·运维
赛希咨询14 小时前
人工智能自动化如何提高研究生产力
运维·人工智能·自动化