配置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
相关推荐
suaizai_12 分钟前
TypeScript 7 正式发布!Vue 暂被 “拒之门外“ !!!
linux·运维·ubuntu
慕伏白1 小时前
【慕伏白】Linux 系统如何根据端口号关闭进程
linux·运维·服务器
letisgo51 小时前
VMware Workstation + Ubuntu 26.04 LTS 小白运维部署手册
linux·运维·ubuntu
蓝创工坊Blue Foundry2 小时前
图片文字提取到 Excel:批量任务如何先定义要交付的字段
运维·服务器·开发语言·数据库·自动化·ocr·excel
Xu_youyaxianshen2 小时前
Git 零基础常用指令手册(Gitee / GitHub 通用 )
git·gitee·github
晚风吹长发2 小时前
Docker使用——Docker容器及相关命令
linux·运维·服务器·docker·容器·架构
ShiXZ2132 小时前
Docker Compose 安装与配置指南
运维·docker·容器
麦聪聊数据2 小时前
企业数据市场建设(四):流程闭环与价值运营,让数据市场真正转起来
运维·数据库
是潮汕的灿灿展吖2 小时前
Centos离线部署nfs操作
linux·运维·centos
阿里嘎多学长3 小时前
2026-07-22 GitHub 热点项目精选
开发语言·程序员·github·代码托管