配置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
相关推荐
阿里嘎多学长26 分钟前
2026-02-07 GitHub 热点项目精选
开发语言·程序员·github·代码托管
比奇堡派星星1 小时前
sed命令
linux·运维·服务器·开发语言
程序员zgh1 小时前
Linux 内存管理单元 MMU
linux·运维·服务器·c语言·开发语言·c++
比奇堡派星星1 小时前
linux基础命令
运维
Trouvaille ~2 小时前
【Linux】TCP协议基础与连接管理详解:从三次握手到四次挥手
linux·运维·服务器·网络·c++·网络协议·tcp/ip
UP_Continue3 小时前
Linux--动静态库
linux·运维·服务器
CheungChunChiu3 小时前
Linux 音频系统全景解析:PipeWire、PulseAudio 与 ALSA 的层次关系
linux·运维·服务器·audio
你真是饿了3 小时前
7.进程间通信
linux·运维·服务器
TEC_INO3 小时前
Linux_12:通过多线程获取VENC的H264码流数据
linux·运维·服务器
跨境小技3 小时前
如何从eBay抓取商品价格数据?2026 eBay数据采集实用方案
大数据·运维