配置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 "[email protected]"

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 "[email protected]"

# 配置
Host github.com
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_ed25519
相关推荐
寻月隐君23 分钟前
探索Web3新速度:Sonic高性能Layer-1上的BlindAuction智能合约实践
后端·web3·github
油泼辣子多加26 分钟前
2025年06月07日Github流行趋势
github
Moment1 小时前
给大家推荐一个超好用的 Marsview 低代码平台 🤩🤩🤩
前端·javascript·github
cui_win1 小时前
每日一令:Linux 极简通关指南 - 汇总
linux·运维·服务器
知星小度S1 小时前
Linux权限探秘:驾驭权限模型,筑牢系统安全
linux·运维·服务器
独立开阀者_FwtCoder2 小时前
stagewise:让AI与代码编辑器无缝连接
前端·javascript·github
Kaede64 小时前
如何应对Linux云服务器磁盘空间不足的情况
linux·运维·服务器
Kookoos7 小时前
Dynamics 365 Finance + Power Automate 自动化凭证审核
运维·自动化·dynamics 365·power automate
努力学习的小廉11 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗11 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器