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:
parent
43c1827fbd
commit
8ce9a600dd
1 changed files with 8 additions and 1 deletions
9
.github/workflows/cd.yml
vendored
9
.github/workflows/cd.yml
vendored
|
|
@ -51,16 +51,23 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
install -m 700 -d ~/.ssh
|
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
|
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'
|
cat > ~/.ssh/config <<'EOF'
|
||||||
Host bastion
|
Host bastion
|
||||||
HostName 103.195.236.32
|
HostName 103.195.236.32
|
||||||
User root
|
User root
|
||||||
|
IdentityFile ~/.ssh/id_ed25519
|
||||||
StrictHostKeyChecking accept-new
|
StrictHostKeyChecking accept-new
|
||||||
Host prod
|
Host prod
|
||||||
HostName 100.109.54.207
|
HostName 100.109.54.207
|
||||||
User neurosus
|
User neurosus
|
||||||
|
IdentityFile ~/.ssh/id_ed25519
|
||||||
ProxyJump bastion
|
ProxyJump bastion
|
||||||
StrictHostKeyChecking accept-new
|
StrictHostKeyChecking accept-new
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue