diff --git a/%E9%85%8D%E7%BD%AE-Git-SSH-%E4%B8%8E-Gitea-%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97.md b/%E9%85%8D%E7%BD%AE-Git-SSH-%E4%B8%8E-Gitea-%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97.md index 4464851..cca11b8 100644 --- a/%E9%85%8D%E7%BD%AE-Git-SSH-%E4%B8%8E-Gitea-%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97.md +++ b/%E9%85%8D%E7%BD%AE-Git-SSH-%E4%B8%8E-Gitea-%E9%9B%86%E6%88%90%E6%8C%87%E5%8D%97.md @@ -6,18 +6,18 @@ ssh-keygen -t ed25519 -C "your_email@example.com" - -t ed25519 指定使用 Ed25519 加密算法(推荐,安全性高) - -C 后面添加注释,通常是你的邮箱地址,用于标识该密钥 -按提示选择保存路径(默认为 `~/.ssh/id_ed25519`)并设置可选的密码(passphrase)。完成后会生成两个文件: + 按提示选择保存路径(默认为 `~/.ssh/id_ed25519`)并设置可选的密码。完成后会生成两个文件: - 私钥:id_ed25519(请勿泄露) - 公钥:id_ed25519.pub(用于上传到 Gitea) -提示:如果你使用的是较老系统不支持 Ed25519,可以改用 `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"`。 - + 提示:如果你使用的是较老系统不支持 Ed25519,可以改用 `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"`。 # 将公钥添加到 Gitea 账户 - 1. 登录你的 Gitea 实例:http://175.27.253.162:3000/ 2. 点击右上角用户头像 → Settings(设置) + ![图片描述](https://cdn.nlark.com/yuque/0/2025/png/439279/1762324187332-050b0a2b-2442-4e46-b199-190db0ed6251.png?x-oss-process=image%2Fformat%2Cwebp) + 3. 在左侧菜单中选择 SSH / GPG 密钥 → 管理 SSH 密钥 4. 打开公钥文件(如 ~/.ssh/id_ed25519.pub),复制其全部内容 ```bash @@ -26,6 +26,7 @@ ssh-keygen -t ed25519 -C "your_email@example.com" 5. 在 Gitea 的 密钥内容文本框中粘贴公钥内容 6. 密钥名称可填写设备名称 7. 点击 **添加密钥** 完成添加 + ![图片描述](https://cdn.nlark.com/yuque/0/2025/png/439279/1762324455534-d8183137-45cb-4db0-9f7a-3cc974d658e2.png?x-oss-process=image%2Fformat%2Cwebp) ![图片描述](https://cdn.nlark.com/yuque/0/2025/png/439279/1762324667835-89aed33a-384d-4d06-a38e-a615574c3cbe.png?x-oss-process=image%2Fformat%2Cwebp) @@ -38,6 +39,6 @@ ssh -T ssh://git@175.27.253.162:222 首次连接时会提示确认主机指纹,请输入` yes` 继续。如果配置正确,应看到类似以下输出: ```bash Hi username! You've successfully authenticated, but Gitea does not provide shell access. -```` +``` 这表示 SSH 认证已生效。 ![图片描述](https://cdn.nlark.com/yuque/0/2025/png/439279/1762324942291-97dc298e-fc03-47cb-a9fc-cd7d81a79d78.png?x-oss-process=image%2Fformat%2Cwebp)