Initial commit: Terraform configurations for multiple cloud providers

This commit is contained in:
Ben User
2026-02-01 06:36:02 +00:00
commit 70f160b396
58 changed files with 1813 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
# Gitea 部署密钥配置指南
## 密钥信息
我们创建了使用 Ed25519 算法的 SSH 密钥对,这是目前最安全的 SSH 密钥算法之一。
## 密钥文件
- **私钥**: `gitea_deploy_key_ed25519`
- **公钥**: `gitea_deploy_key_ed25519.pub`
## 在 Gitea 中配置部署密钥
### 1. 添加部署密钥到 Gitea 仓库
1. 登录到你的 Gitea 实例
2. 导航到你的私有仓库
3. 点击 "Settings"(设置)
4. 在左侧菜单中选择 "Deploy Keys"(部署密钥)
5. 点击 "Add Key"(添加密钥)
6. 输入密钥标题,例如 "Deployment Key"
7. 将以下公钥内容粘贴到密钥字段中:
```
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB1Eiqridn8nvb0nzwX5qfkN7Z4U94vKtvCBf0pbDHvz gitea-deploy-key@private
```
8. 选择适当的权限(通常选择 "Read" 权限用于部署)
9. 点击 "Add Key"(添加密钥)
### 2. 配置服务器使用私钥
将私钥 `gitea_deploy_key_ed25519` 安装到你的部署服务器上:
1. 将私钥复制到服务器上的 `~/.ssh/` 目录
2. 设置正确的权限:
```bash
chmod 600 ~/.ssh/gitea_deploy_key_ed25519
```
3. 配置 SSH 客户端使用此密钥(在 `~/.ssh/config` 中):
```
Host your-gitea-host.com
IdentityFile ~/.ssh/gitea_deploy_key_ed25519
User git
```
### 3. 在 CI/CD 中使用
如果你在 CI/CD 系统中使用此密钥:
1. 将私钥内容作为密钥存储在 CI/CD 系统中
2. 在构建脚本中创建临时 SSH 配置:
```bash
mkdir -p ~/.ssh
echo "$GITEA_DEPLOY_KEY" > ~/.ssh/gitea_deploy_key_ed25519
chmod 600 ~/.ssh/gitea_deploy_key_ed25519
```
## 安全注意事项
- 保护好私钥文件,不要将其提交到代码仓库
- 定期轮换部署密钥建议每6-12个月
- 使用最小权限原则,只为密钥分配必要的访问权限
- 监控密钥的使用情况
## 备用密钥
我们也保留了 ECDSA 密钥作为备用选项,但建议优先使用 Ed25519 密钥。

View File

@@ -0,0 +1,69 @@
# SSH 密钥使用说明
## 默认 SSH 密钥配置
我们已创建了 Ed25519 加密的 SSH 密钥对,作为你的默认 SSH 密钥。
### 密钥文件位置
- **私钥**: `/home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519`
- **公钥**: `/home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519.pub`
- **SSH 配置**: `/home/ben/terraform/ssh_keys/config`
### 如何使用(推荐方法)
由于安全限制,我们不能直接修改你的主目录下的 `.ssh` 文件夹。请按以下步骤使用这些密钥:
#### 方法 1: 复制配置文件
```bash
# 备份现有配置(如有)
cp ~/.ssh/config ~/.ssh/config.backup 2>/dev/null || true
# 复制新的配置
cp /home/ben/terraform/ssh_keys/config ~/.ssh/config
# 设置正确的权限
chmod 600 ~/.ssh/config
```
#### 方法 2: 手动添加到现有配置
如果已有 SSH 配置,可将以下内容追加到 `~/.ssh/config`
```
# 默认使用 Ed25519 密钥
Host *
IdentityFile /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519
IdentitiesOnly yes
```
### 验证密钥
要验证 SSH 密钥是否正常工作:
```bash
# 测试 SSH 连接
ssh -T -i /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519 git@your-gitea-server.com
```
### 权限设置
确保密钥文件有正确的权限:
```bash
chmod 600 /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519
chmod 644 /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519.pub
```
### 在 Gitea 中使用
1. 将公钥内容添加到 Gitea 的部署密钥中
2. 公钥内容可通过以下命令查看:
```bash
cat /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519.pub
```
### 安全提示
- 保护好私钥文件,不要分享给他人
- 定期更换密钥建议每6-12个月
- 使用 `IdentitiesOnly yes` 可防止 SSH 代理泄露

18
ssh_keys/config Normal file
View File

@@ -0,0 +1,18 @@
# SSH Config for Default Key Usage
# 默认使用 Ed25519 密钥
Host *
IdentityFile /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519
IdentitiesOnly yes
# Gitea 专用配置
Host gitea.*
IdentityFile /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519
User git
IdentitiesOnly yes
# 火山引擎相关配置
Host *.volces.com
IdentityFile /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519
User git
IdentitiesOnly yes