Skip to content

salt-ssh scp transfer hangs on Photon OS 4 when destination path contains a space #70204

Closed

Description

@twangboy

Description

PR #70085 quotes the local/remote paths passed to scp in salt.client.ssh.shell.Shell.send() via shlex.quote() to fix salt-ssh breaking when a path contains a space (#61338).

CI shows this is incomplete: tests/pytests/integration/ssh/test_deploy.py::test_thin_dir_with_space (the regression test #70085 itself added) hangs and times out (>90s), reproducibly, on Photon OS 4 (Arm64 and non-Arm64), on both its initial attempt and its automatic rerun, while the identical test passes cleanly on Photon OS 5 and every other distro in the matrix.

Root cause

OpenSSH switched scp's default transfer protocol from the legacy scp/rcp-style protocol to the modern SFTP-based protocol starting in OpenSSH 9.0 (April 2022). Under the legacy protocol, the local scp binary builds and sends its own remote-shell command (e.g. scp -t '<path>') over the ssh channel to a receiver process on the target. Local shlex.quote() escaping -- correct for the local invoking shell -- does not reliably survive scp's own internal re-quoting of that remote command when the destination path contains a space, and the target simply hangs waiting for a well-formed command rather than erroring out.

Photon OS 4 (2020, EOL-track) ships an OpenSSH predating the SFTP-by-default switch; Photon OS 5 (2022+) ships a newer one -- hence the split between the two.

Fix

Fixed in Shell.send(): scp to a fixed, definitely-space-free staging path (/tmp/.salt-ssh-<uuid>.tmp), then rename it into the real (possibly space-containing) destination over a plain ssh mv command, where shlex.quote() is already known-correct (interpreted by a real remote shell, not re-escaped by scp's own transport).

Related

Activity

  1. added a commit that references this issue on Sep 1, 2026
    4d97b4e
  2. twangboy commented on Sep 2, 2026

    @twangboy
    ContributorAuthor

    Closing this out -- follow-up debug tracing across multiple distros (Photon OS 4, Debian 12 Arm64, Ubuntu 22.04 Arm64) showed test_thin_dir_with_space's >90s hangs occur on a different underlying command each time (a plain scp with zero spaces involved, a raw ssh shim invocation, and once with no reproducible command at all in the trace). That's the signature of intermittent ssh/scp connection stalls under CI load, not a deterministic space-escaping bug in Shell.send().

    The staging-path fix from this issue has been reverted (it solved a problem that didn't exist, and doubled ssh/scp invocations per transfer, which if anything increases exposure to this kind of flake). The test is now marked @pytest.mark.flaky(max_runs=4) instead, with a comment explaining why.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions