配置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
相关推荐
mobai744 分钟前
Ubuntu环境上安装NTP服务
linux·运维·ubuntu
loong_XL5 小时前
docker gpu容器镜像环境构建
运维·docker·容器
杨了个杨89826 小时前
nginx常见功能部署
运维·服务器·nginx
小天源8 小时前
linux漏洞一键扫描
linux·运维·服务器·漏洞扫描
eWidget8 小时前
InfluxDB迁移至金仓数据库的同城容灾实践:性能显著提升、运维效率优化,某能源企业实现RPO_5秒的高可靠时序数据管理
运维·数据库·能源·时序数据库·kingbase·kingbasees·金仓数据库
m0_696212688 小时前
个人微信api
运维·服务器
CoderJia程序员甲8 小时前
GitHub 热榜项目 - 日榜(2026-01-26)
ai·开源·大模型·github·ai教程
en-route9 小时前
SSH Key 与 GPG Key 区别详解:Git 使用中的身份与签名机制
运维·git·ssh
轻抚酸~9 小时前
使用git维护github项目的简单实践
git·github
小白鸽i11 小时前
【LINUX】将源码驱动文件编译并生效
linux·运维·服务器