Skip to content

[Helper] Support non-root SSH users for cold standby - #7371

Open
pi0n00r wants to merge 1 commit into
mailcow:stagingfrom
pi0n00r:feat/non-root-cold-standby
Open

[Helper] Support non-root SSH users for cold standby#7371
pi0n00r wants to merge 1 commit into
mailcow:stagingfrom
pi0n00r:feat/non-root-cold-standby

Conversation

@pi0n00r

@pi0n00r pi0n00r commented Jul 26, 2026

Copy link
Copy Markdown

Contribution Guidelines

What does this PR include?

Short Description

This PR allows the cold-standby destination to be reached through a non-root
SSH account while preserving root as the default.

It is a clean reimplementation, based directly on current staging, of the
remote-user goal previously raised in #6612 and #6613. It contains no unrelated
history and no watchdog changes.

The helper now:

  • accepts REMOTE_SSH_USER, defaulting to root;
  • defaults an omitted REMOTE_SSH_PORT to 22;
  • uses one SSH command path for the configured user, key, port, and host-key
    policy;
  • treats a non-root user as an SSH transport identity and explicitly requires
    root-equivalent sudo -n access during preflight;
  • runs destination filesystem, Docker, Compose, and service operations through
    non-interactive sudo for non-root users;
  • supplies sudo -n rsync as the remote rsync path when required;
  • accepts directory-backed SSH principals through SSH's -l option; and
  • keeps the existing root command path and host-key policy defaults.

The tracked launcher remains root-compatible and documents the non-root option.

Affected Containers

  • None (helper scripts only)

Did you run tests?

Yes.

What did you test?

  • helper-scripts/tests/test_cold_standby_non_root.sh
  • Bash syntax for the launcher and cold-standby helper
  • ShellCheck at error severity for both upstream scripts
  • Full ShellCheck for the new fixture test
  • Root and non-root target construction
  • Root and non-root remote rsync command selection
  • Exact SSH argument construction, including a key path containing spaces
  • Non-root privileged command construction and failure propagation
  • Static checks that no hard-coded root@... target remains

This candidate has not yet been exercised in a fresh end-to-end standby
migration.

What were the final results? (Awaited, got)

Expected:

  • existing root destinations retain their current command path;
  • non-root destinations fail preflight unless passwordless sudo is available;
  • non-root rsync and privileged destination operations use sudo -n; and
  • invalid user/port configuration fails before data transfer.

Got:

  • the deterministic test passed;
  • Bash syntax checks passed;
  • ShellCheck reported no errors in the touched scripts; and
  • the new test script passed full ShellCheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant