From 80171575a6df5a6636341e76244c386def0f83f2 Mon Sep 17 00:00:00 2001 From: SkyLiCoder Date: Tue, 14 Apr 2026 02:07:42 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=8C=87=E5=8D=97=201=20SSH=E5=AF=86=E9=92=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SSH%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE.md | 147 +++++++++--------- 1 file changed, 75 insertions(+), 72 deletions(-) diff --git a/%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97-1-SSH%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE.md b/%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97-1-SSH%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE.md index 5820739..6c8e8ec 100644 --- a/%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97-1-SSH%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE.md +++ b/%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97-1-SSH%E5%AF%86%E9%92%A5%E9%85%8D%E7%BD%AE.md @@ -1,72 +1,75 @@ -# SSH 密钥配置 - -本文介绍如何创建 SSH 公私钥对并添加到 Gitea。 - -## 1. 创建 SSH 公私钥对 - -如果没有现成的 SSH 密钥对,需要先生成一对。 - -### 生成命令 - -```bash -ssh-keygen -t ed25519 -C "your_email@example.com" -``` - -**参数说明:** -- `-t ed25519`:使用 Ed25519 算法(推荐,比 RSA 更安全、更短) -- `-C "your_email@example.com"`:注释,通常填你的邮箱,便于识别 - -### 交互提示 - -``` -Generating public/private ed25519 key pair. -Enter file in which to save key (/home/you/.ssh/id_ed25519): # 直接回车使用默认路径 -Enter passphrase (empty for no passphrase): # 输入密码短语,建议设置,若不设置则直接回车 -Enter same passphrase again: # 确认密码短语,若不设置则直接回车 -``` - -> **注意**:密码短语是你对私钥的额外保护,即使他人拿到私钥文件,没有密码也无法使用。请妥善保管,不要遗忘。 - -### 生成的文件 - -| 文件 | 说明 | -|------|------| -| `~/.ssh/id_ed25519` | 私钥(**不要泄露**) | -| `~/.ssh/id_ed25519.pub` | 公钥(需要填到 Gitea) | - -### 确认文件存在 - -```bash -ls -la ~/.ssh/id_ed25519* -``` - ---- - -## 2. 在 Gitea 上添加公钥 - -### 步骤 - -1. **获取公钥内容** - - ```bash - cat ~/.ssh/id_ed25519.pub - ``` - - 输出类似于: - ``` - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBLABELOCATED/ahKwj98dsfsaf+ASDNo7your_email@example.com - ``` - -2. **登录 Gitea** - - 打开团队 Gitea 地址(如 `https://gitea.your-team.com`),登录你的账号。 - -3. **添加公钥** - - - 点击右上角头像 → **设置(Settings)** - - 左侧菜单找到 **SSH 密钥(SSH Keys)** - - 点击 **添加密钥(Add Key)** - - 填写: - - **标题(Title)**:给密钥起个名字,如 `我的笔记本` 或 `Desktop-PC` - - **密钥(Key)**:粘贴上一步 `cat` 输出的完整内容 - - 点击 **添加(Add Key)** +# SSH 密钥配置 + +本文介绍如何创建 SSH 公私钥对并添加到 Gitea。 + +## 1. 创建 SSH 公私钥对 + +如果没有现成的 SSH 密钥对,需要先生成一对。 + +### 生成命令 + +```bash +ssh-keygen -t ed25519 -C "your_email@example.com" +``` + +**参数说明:** +- `-t ed25519`:使用 Ed25519 算法(推荐,比 RSA 更安全、更短) +- `-C "your_email@example.com"`:注释,通常填你的邮箱,便于识别 + +### 交互提示 + +``` +Generating public/private ed25519 key pair. +Enter file in which to save key (/home/you/.ssh/id_ed25519): # 直接回车使用默认路径 +Enter passphrase (empty for no passphrase): # 输入密码短语,建议设置,若不设置则直接回车 +Enter same passphrase again: # 确认密码短语,若不设置则直接回车 +``` + +> **注意**:密码短语是你对私钥的额外保护,即使他人拿到私钥文件,没有密码也无法使用。请妥善保管,不要遗忘。 + +### 生成的文件 + +| 文件 | 说明 | +|------|------| +| `~/.ssh/id_ed25519` | 私钥(**不要泄露**) | +| `~/.ssh/id_ed25519.pub` | 公钥(需要填到 Gitea) | + +### 确认文件存在 + +```bash +ls -la ~/.ssh/id_ed25519* +``` + +--- + +## 2. 在 Gitea 上添加公钥 + +### 步骤 + +1. **获取公钥内容** + + ```bash + cat ~/.ssh/id_ed25519.pub + ``` + + 输出类似于: + ``` + ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBLABELOCATED/ahKwj98dsfsaf+ASDNo7your_email@example.com + ``` + +2. **登录 Gitea** + + 打开团队 Gitea 地址(如 `https://gitea.your-team.com`),登录你的账号。 + +3. **添加公钥** + + - 点击右上角头像 → **设置(Settings)** + - 左侧菜单找到 **SSH 密钥(SSH Keys)** + - 点击 **添加密钥(Add Key)** + - 填写: + - **标题(Title)**:给密钥起个名字,如 `我的笔记本` 或 `Desktop-PC` + - **密钥(Key)**:粘贴上一步 `cat` 输出的完整内容 + - 点击 **添加(Add Key)** + + +- [开发指南-2-连接验证](./%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97-2-%E8%BF%9E%E6%8E%A5%E9%AA%8C%E8%AF%81) \ No newline at end of file