Skip to content

Fix SSH attach control socket path length#4013

Closed
peterschmidt85 wants to merge 1 commit into
masterfrom
fix-ssh-control-socket-path
Closed

Fix SSH attach control socket path length#4013
peterschmidt85 wants to merge 1 commit into
masterfrom
fix-ssh-control-socket-path

Conversation

@peterschmidt85

@peterschmidt85 peterschmidt85 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Problem
dstack attach can fail with OpenSSH ControlPath too long before it connects.

How to reproduce
Run attach with a long ~/.dstack path 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.sock

That path was over the Unix socket path limit, so OpenSSH rejected it.

Why it happens
dstack attach used:

~/.dstack/ssh/<run-name>.control.sock

That 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>.sock

Keep the old path only as fallback when /tmp cannot 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>.sock keeps the path short and stable. The per-user directory is checked for owner, permissions, and symlinks before use.

AI Assistance: Used Codex.

@peterschmidt85 peterschmidt85 requested a review from un-def July 8, 2026 15:39
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