Files
terraform/ssh_keys/USAGE_INSTRUCTIONS.md

1.8 KiB
Raw Permalink Blame History

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: 复制配置文件

# 备份现有配置(如有)
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 密钥是否正常工作:

# 测试 SSH 连接
ssh -T -i /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519 git@your-gitea-server.com

权限设置

确保密钥文件有正确的权限:

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. 公钥内容可通过以下命令查看:
    cat /home/ben/terraform/ssh_keys/gitea_deploy_key_ed25519.pub
    

安全提示

  • 保护好私钥文件,不要分享给他人
  • 定期更换密钥建议每6-12个月
  • 使用 IdentitiesOnly yes 可防止 SSH 代理泄露