fix: sanitize CD ssh key (strip CR) and fail fast on bad key

Paste tu Windows/chat hay dinh CRLF lam hong key tren runner (libcrypto). Loc CR, validate bang ssh-keygen -lf, pin IdentityFile.
This commit is contained in:
hailt 2026-11-02 11:05:42 +07:00
parent 43c1827fbd
commit 8ce9a600dd

View file

@ -51,16 +51,23 @@ jobs:
run: |
set -euo pipefail
install -m 700 -d ~/.ssh
printf '%s\n' "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
# Loc ky tu CR (secret paste tu Windows/chat hay dinh CRLF lam hong key).
printf '%s\n' "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
# Fail som neu key hong: in armor + fingerprint (khong lo secret) de doi chieu.
head -n 1 ~/.ssh/id_ed25519
tail -n 1 ~/.ssh/id_ed25519
ssh-keygen -lf ~/.ssh/id_ed25519
cat > ~/.ssh/config <<'EOF'
Host bastion
HostName 103.195.236.32
User root
IdentityFile ~/.ssh/id_ed25519
StrictHostKeyChecking accept-new
Host prod
HostName 100.109.54.207
User neurosus
IdentityFile ~/.ssh/id_ed25519
ProxyJump bastion
StrictHostKeyChecking accept-new
EOF