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.
相关推荐
宝桥南山2 分钟前
GitHub Copilot - 尝试使用一下Azure Devops MCP server
microsoft·微软·github·aigc·copilot·devops
MicrosoftReactor3 分钟前
技术速递|提升 GitHub Agentic Workflows 的 Token 使用效率
ai·github·copilot·智能体
DogDaoDao18 分钟前
【GitHub】last30days-skill 深度技术解析
深度学习·程序员·大模型·github·ai agent·agent skill
IT WorryFree19 分钟前
GitHub / Gitee / Gitea / GitLab 四平台完整对比(定位、优缺点、适用场景)
gitee·github·gitea
BugShare30 分钟前
Mac 上原生开发的开源免费、尽享丝滑数据库工具
数据库·macos·开源
Dontla31 分钟前
Github Personal Access Token(个人访问令牌)添加workflow scope(更新GitHub Actions工作流文件必须)
github
難釋懷37 分钟前
Nginx对上游服务器使用keepalive
服务器·nginx·github
Lethehong43 分钟前
去芜存菁:NextChat 本地部署与物流“数字客服”的优雅落地
ai·github·蓝耘·蓝耘元生代
DogDaoDao1 小时前
【GitHub】深度解析 Open Notebook:开源 AI 笔记研究平台的完整指南
人工智能·ai·程序员·开源·github·ai编程·notebook
Soari1 小时前
开源项目apple/container 解析:Apple 官方推出的 macOS 原生容器运行工具
macos·开源