This commit is contained in:
1
2026-01-27 03:05:37 +00:00
parent 6c4630708d
commit 7e3fec7282

View File

@@ -30,8 +30,25 @@ steps:
- mkdir -p /root/.ssh && chmod 700 /root/.ssh
# 写入并清理SSH密钥兼容RSA/ED25519保留原始换行
# 替换原echo "$WOODPECKER_SSH_KEY"那行其余ssh配置不变
- echo "$WOODPECKER_SSH_KEY" > /root/.ssh/id_ed25519 && chmod 600 /root/.ssh/id_ed25519
# ========== 关键修改SSH密钥写入逻辑核心修复 ==========
# 替换原echo命令用cat+EOF保留密钥原始换行避免格式损坏
- |
if [ -n "$WOODPECKER_SSH_KEY" ]; then
# 写入ED25519密钥保留原始格式单引号EOF避免转义
cat > /root/.ssh/id_ed25519 << 'EOF'
$WOODPECKER_SSH_KEY
EOF
chmod 600 /root/.ssh/id_ed25519
echo "✅ ED25519密钥写入完成"
# 可选兼容RSA密钥如果ED25519解析失败启用下方逻辑
# elif [ -n "$WOODPECKER_SSH_KEY_RSA" ]; then
# cat > /root/.ssh/id_rsa << 'EOF'
# $WOODPECKER_SSH_KEY_RSA
# EOF
# chmod 600 /root/.ssh/id_rsa
# echo "✅ RSA密钥写入完成"
# fi
- chmod 600 /root/.ssh/id_ed25519
# 添加GitHub主机密钥完整覆盖避免重复
- ssh-keyscan -H github.com > /root/.ssh/known_hosts