Skip to content

Commit ac1eaaf

Browse files
bors[bot]zimbatm
andauthored
Merge #79
79: fix small security race r=Mic92 a=zimbatm Co-authored-by: zimbatm <zimbatm@zimbatm.com>
2 parents ee5c39f + eafa9cf commit ac1eaaf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

terraform/nixos-rebuild/deploy.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ sshOpts+=(-o StrictHostKeyChecking=no)
2121

2222
if [[ -n ${SSH_KEY+x} && ${SSH_KEY} != "-" ]]; then
2323
sshPrivateKeyFile="$workDir/ssh_key"
24-
trap 'rm "$sshPrivateKeyFile"' EXIT
25-
echo "$SSH_KEY" >"$sshPrivateKeyFile"
26-
chmod 0700 "$sshPrivateKeyFile"
24+
# Create the file with 0700 - umask calculation: 777 - 700 = 077
25+
(
26+
umask 077
27+
echo "$SSH_KEY" >"$sshPrivateKeyFile"
28+
)
2729
unset SSH_AUTH_SOCK # don't use system agent if key was supplied
2830
sshOpts+=(-o "IdentityFile=${sshPrivateKeyFile}")
2931
fi

0 commit comments

Comments
 (0)