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.
相关推荐
greasyfork20 分钟前
多种数据库管理混乱?Navicat Premium 17 for Mac 统一解决
数据库·mysql·macos·mac
胡萝卜术1 小时前
从聊天模型到本地执行助手:Remote MCP 多工具 Agent 实战
面试·架构·github
碎_浪2 小时前
Mac 壁纸被 MDM 锁住?我做了个 2MB 的开源方案
macos·开源·swift
慕容引刀4 小时前
告别Commit信息纠结:使用Git AI Commit插件实现规范化提交
人工智能·git·github·visual studio code·visual studio
逆向编程4 小时前
AI编程CLI两种配置方案(macOS专用)
macos·ai编程
沐禾安信4 小时前
开会来不及记录?Mac 录屏方法收好
macos·音视频·电脑录屏
GoGeekBaird13 小时前
我开源了 BeeWeave,给 AI Agent 搭一个越用越懂你的知识创作台
后端·github
fthux14 小时前
GitZip Pro 源码解析:一个 GitHub 文件/文件夹下载扩展是如何工作的(一)整体架构与扩展入口
人工智能·ai·开源·github·open source
ITKEY_14 小时前
macOS brew 安装的nginx 文件在哪里?
运维·nginx·macos
第一程序员15 小时前
Rust Agent 子进程执行:Command 之前,先定义输入和超时
python·rust·github