配置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 小时前
HAProxy高级功能全解析
linux·运维·服务器·微服务·云原生
小李独爱秋2 小时前
“bootmgr is compressed”错误:根源、笔记本与台式机差异化解决方案深度指南
运维·stm32·单片机·嵌入式硬件·文件系统·电脑故障
Dying.Light3 小时前
Linux部署问题
linux·运维·服务器
S19013 小时前
Linux的常用指令
linux·运维·服务器
萤丰信息3 小时前
AI 筑基・生态共荣:智慧园区的价值重构与未来新途
大数据·运维·人工智能·科技·智慧城市·智慧园区
小义_4 小时前
【RH134知识点问答题】第7章 管理基本存储
linux·运维·服务器
运维小欣4 小时前
Agentic AI 与 Agentic Ops 驱动,智能运维迈向新高度
运维·人工智能
_运维那些事儿5 小时前
VM环境的CI/CD
linux·运维·网络·阿里云·ci/cd·docker·云计算
Trouvaille ~6 小时前
【Linux】UDP Socket编程实战(一):Echo Server从零到一
linux·运维·服务器·网络·c++·websocket·udp
嵌入小生0076 小时前
Shell | 命令、编程及Linux操作系统的基本概念
linux·运维·服务器