配置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
相关推荐
syagain_zsx1 小时前
Linux指令初识(实用篇)
linux·运维·服务器
OYangxf1 小时前
Git Commit Message
运维·git
Alter12301 小时前
从“力大砖飞”到“拟态共生”,新华三定义AI基础设施的系统级进化
大数据·运维·人工智能
王木风2 小时前
终端里的编程副驾:DeepSeek-TUI-项目深度拆解,实测与原理分析
linux·运维·人工智能·rust·node.js
槑槑紫2 小时前
windows系统装轻量版linux开发
linux·运维·服务器
齐潇宇2 小时前
k8s-Helm管理器
linux·运维·云原生·容器·kubernetes
白鲸开源2 小时前
杀疯了!SeaTunnel AI CLI 解锁数据集成新玩法
大数据·人工智能·github
Skylwn3 小时前
保姆级教程之将 GitHub Models 接入 NewAPI
笔记·github
小王C语言3 小时前
Windows和Linux之间文件互传
linux·运维·服务器
Better Bench4 小时前
Claude Code 学习指南:优秀 GitHub 仓库推荐与进阶路线图
github·claude code·学习指南