Skip to content

Commit 6f97240

Browse files
committed
fix(setup): grant NOPASSWD sudo to the bootstrapped deploy user
shipnode's non-interactive setup/harden/deploy all assume sudo doesn't prompt (the $SUDO pattern shells out and never handles a password). syncUsers puts the user in the sudo group but that still requires a password, so subsequent shipnode harden / shipnode deploy runs as deploy would hang or fail. Drop a NOPASSWD:ALL sudoers.d file right after user creation. Industry standard for CI/deploy accounts.
1 parent cba1151 commit 6f97240

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/cli/commands/setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ async function bootstrapDeployUser(
6868
}
6969
ui.info(`Creating '${DEPLOY_USER}' on ${config.ssh.host}...`);
7070
await syncUsers(executor, [entry]);
71+
// Grant NOPASSWD sudo — shipnode's non-interactive setup/harden/deploy all
72+
// assume sudo doesn't prompt. Industry-standard for CI/deploy accounts; the
73+
// tradeoff is that a compromise of the deploy user's SSH key gets root.
74+
await executor.execOrThrow(
75+
`SUDO=""; [ "$EUID" -ne 0 ] && SUDO="sudo"; ` +
76+
`echo "${DEPLOY_USER} ALL=(ALL) NOPASSWD:ALL" | $SUDO tee "/etc/sudoers.d/shipnode-${DEPLOY_USER}" > /dev/null && ` +
77+
`$SUDO chmod 440 "/etc/sudoers.d/shipnode-${DEPLOY_USER}"`,
78+
);
7179
return true;
7280
}
7381

0 commit comments

Comments
 (0)