MacOS 本地生成SSH key并关联Github

生成一个名字叫key_github的ssh key pair,目录在~/.ssh/,文件名可以按自己喜好修改,邮箱用自己的

复制代码
ssh-keygen -t rsa -b 4096 -C "xxxx@email.com" -f ~/.ssh/key_github

生成完记得激活加入ssh agent:

复制代码
eval "$(ssh-agent -s)"
你会看见提示:
Agent pid 12345

将生成的ssh 加入agent:

复制代码
ssh-add ~/.ssh/key_github

这时候~/.ssh 目录下应该会有两个文件,key_github 和 key_github.pub,用textEditor打开pub文件,复制里面的内容,

登陆github,右上角头像,点击settings,在左侧选择SSH and GPG keys,右边 add new ssh keys,粘贴刚才复制的内容,save

这样github获取了共钥,而本地macbook保留着私钥,就可以ssh连接了

打开terminal测试连接

复制代码
ssh -T git@github.com 

提示
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
相关推荐
u13013016 小时前
GitHub 热榜项目:周榜(2026-08-09)
github
向上的车轮16 小时前
GitHub Actions 自动化运维实战:Java + TypeScript 全栈项目 CI/CD 至阿里云
运维·自动化·github
2601_9657984716 小时前
Launch Your Wellness App Fast: The Truth About Meditation Source Code
前端·macos·ios·objective-c·cocoa
万少1 天前
我是如何感觉到被时代抛弃的
github
汪海游龙1 天前
告别 Play Console 手动上传:从模拟器截图到自动发版的完整流水线
android·ci/cd·github
沫璃染墨1 天前
《从零入门Linux系统篇(十四):系统工具篇·五——Git版本控制:从版本管理到协同开发》
linux·运维·服务器·git·gitee·github
fthux1 天前
装闭 RenoPit 源码解析(02):AI装修闭坑系统数据库与模型设计
人工智能·ai·开源·github·open source·renopit
本地化文档2 天前
skbuild-docs-l10n
python·github·gitcode·sphinx
XS0301062 天前
GitHub/Gitee 团队协作笔记
笔记·gitee·github
csdn_aspnet2 天前
在 Visual Studio Code 中安装使用 Github Copilot
ide·vscode·github·copilot