From 8ce9a600ddf020bc584b1d78754b5fccfe7ef5a7 Mon Sep 17 00:00:00 2001 From: hailt Date: Mon, 2 Nov 2026 11:05:42 +0700 Subject: [PATCH] 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. --- .github/workflows/cd.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 428779f..c37ee2a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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