Fix SSH attach control socket path length#4013
Closed
peterschmidt85 wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dstack attachcan fail with OpenSSHControlPath too longbefore it connects.How to reproduce
Run attach with a long
~/.dstackpath and a long run name. Example from the failing case:/Users/dstack/.dstack/server/data/endpoint_agent_runs/.../home/.dstack/ssh/qwen36-27b-existing-auth-e2e-2-1.control.sockThat path was over the Unix socket path limit, so OpenSSH rejected it.
Why it happens
dstack attachused:~/.dstack/ssh/<run-name>.control.sockThat path includes the user home/dstack directory and the run name. In endpoint-agent or other nested environments, it can easily exceed OpenSSH's Unix-domain socket path limit.
Fix
On POSIX, use a short runtime socket path:
/tmp/dstack-ssh-<uid>/<hash>.sockKeep the old path only as fallback when
/tmpcannot be used and the old path is still short enough.Why this fix
The socket is runtime state, not SSH config or key material, so it does not need to live under
~/.dstack/ssh./tmp/dstack-ssh-<uid>/<hash>.sockkeeps the path short and stable. The per-user directory is checked for owner, permissions, and symlinks before use.AI Assistance: Used Codex.