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.
相关推荐
祎直向前3 小时前
vscode实现ssh远程连接
ide·vscode·ssh
BianHuanShiZhe3 小时前
ios 26的tabbar 背景透明
macos·objective-c·cocoa
ai_xiaogui4 小时前
AIStarter跨平台完工:Win/Mac/Linux一键部署Stable Diffusion
linux·macos·stable diffusion·aistarter·kritaai·跨平台部署
c++服务器开发6 小时前
掌握RAG系统的七个优秀GitHub存储库
人工智能·python·github·rag
Macbethad6 小时前
Typora 精通指南:掌握高效 Markdown 写作的艺术
前端·macos·前端框架
杨凯凡8 小时前
Docker环境搭建:Windows/macOS/Linux全平台教程
windows·macos·docker
逛逛GitHub8 小时前
GitHub 上的 3 个 AI 信息差利器,太绝了啊。
git·github
马拉萨的春天8 小时前
iOS的事件响应链
macos·ios·cocoa
bl4ckpe4ch9 小时前
mac安装burpsuite专业版2025中文教程
macos·网络安全·抓包·burpsuite