Ubuntu 配置 Github 的 SSH keys

先进入已有的 Git 目录或使用新建的一个 Git 仓库下。

设置 Github 用户名和邮箱:

shell 复制代码
$ git config --global user.name [Github用户名]
$ git config --global user.email [Github认证邮箱]

生成 SSH 密钥文件:

shell 复制代码
$ ssh-keygen -t rsa -C [Github认证邮箱]
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
[按 Enter 键接受默认文件位置]
Enter passphrase (empty for no passphrase): 
[按 Enter 不设置安全口令, 如果设置, 每次使用 Git 命令时都需要输入]
Enter same passphrase again:
[重复安全口令, 如果上一步没有设置, 按 Enter 跳过]

~/.ssh/ 目录下会创建两个文件:

  • id_rsa: 私钥文件
  • id_rsa.pub: 公钥文件

将公钥文件内容打印后复制:

shell 复制代码
$ cat ~/.ssh/id_rsa.pub

登陆 Github 点击 右上角头像 -> Settings -> SSH and GPG keys -> New SSH key 输入以下内容:

  • Title: 任意取名
  • Key type: Authentication Key
  • Key: 复制上一步中的公钥文件内容到此处

点击 Add SSH key 完成创建, 验证 Authentication 是否正常:

shell 复制代码
$ ssh -T git@github.com
The authenticity of host 'github.com (0.0.0.0)' can't be established.
ED25519 key fingerprint is SHA256:+xxxxxxxxx/xxxxxxxxx.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? 
[选择 yes 使服务器的连接信息保存在系统中]
Warning: Permanently added 'github.com' (ED0000) to the list of known hosts.
Hi [Github用户名]! You've successfully authenticated, but GitHub does not provide shell access.

最后输出 Hi [Github用户名]! You've successfully authenticated, but GitHub does not provide shell access. 就表示配置成功了。

相关推荐
badhope4 小时前
AI Skill 技术全景解析——从“聊天机器人”到“全能战神”的进化之路
架构·github
徐小夕21 小时前
我们用1万行Vue3代码,做了款开源AI PPT项目
github
苏同学1 天前
LangGraph 实战:从零实现多工具协作的可追溯文档问答 Agent
github
逛逛GitHub1 天前
给 OpenClaw 小龙虾🦞搞个像素办公室,这个 GitHub 项目有趣啊。
github
doup智能AI1 天前
数据分析师:报表自动生成与洞察——AI 员工系列 Vol.4
github
答案answer1 天前
Three.js3D编辑器必备的相机视图插件
开源·github·three.js
RickeyBoy2 天前
Git Worktree / Worktrunk:并行 AI 开发工作流实战
github·vibecoding
逛逛GitHub2 天前
55 个 AI Agent 组成虚拟公司开源,2 天就 1 万星
github
Tapir2 天前
被 Karpathy 下场推荐的 NanoClaw 是什么来头
前端·后端·github
ShingingSky2 天前
用 Claude Skill 改造 AgentTeams:我实现了 AI 协作的质变
github