fix: normalize CD ssh key with literal backslash-n
Secret paste dang 1 dong voi backslash-n chu (thay vi newline that) lam key hong. Tu dung lai newline, giu nguyen dang chuan, validate bang ssh-keygen -lf.
This commit is contained in:
parent
8ce9a600dd
commit
5f362ec7d3
1 changed files with 11 additions and 2 deletions
13
.github/workflows/cd.yml
vendored
13
.github/workflows/cd.yml
vendored
|
|
@ -51,8 +51,17 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
install -m 700 -d ~/.ssh
|
install -m 700 -d ~/.ssh
|
||||||
# Loc ky tu CR (secret paste tu Windows/chat hay dinh CRLF lam hong key).
|
# Chuan hoa secret truoc khi ghi key:
|
||||||
printf '%s\n' "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
|
# - Loc ky tu CR (paste tu Windows/chat hay dinh CRLF).
|
||||||
|
# - Neu secret bi paste dang 1 dong voi \n chu (thay vi xuong
|
||||||
|
# dong that) thi dung lai newline that.
|
||||||
|
KEY="$SSH_PRIVATE_KEY"
|
||||||
|
if [ "$(printf '%s' "$KEY" | wc -l)" -eq 0 ]; then
|
||||||
|
case "$KEY" in
|
||||||
|
*\\n*) KEY="$(printf '%b' "$KEY")" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
printf '%s\n' "$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.
|
# Fail som neu key hong: in armor + fingerprint (khong lo secret) de doi chieu.
|
||||||
head -n 1 ~/.ssh/id_ed25519
|
head -n 1 ~/.ssh/id_ed25519
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue