You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The user tries to attach to the run using dstack attach.
The user won't be able to attach and will get the Can't connect to the remote host error.
This happens because the SSH key for attaching is generated in CLI and stored on the machine, so different machines will have different keys, even if the user is the same.
Solution
Generate and store users' SSH keys in dstack-server and download them to the client machine when needed.
This ensures that all of a user's machines have the same key, and the only secret the user needs to access their runs from a new machine is the dstack API token.
Workaround 1
Generate a private+public key pair with ssh-keygen and deliver them to all machines where access to the run in desired.
Before running dstack apply, init the repo with dstack init --ssh-identity <path to private key>
To attach to the run, use dstack attach --ssh-identity <path to private key> <run name>
Workaround 2
Manually copy ~/.dstack/ssh/id_rsa and ~/.dstack/ssh/id_rsa.pub from one machine to the rest.
Would you like to help us implement this feature by sending a PR?
Introduce ssh_private_key and ssh_public_key properties in User in the database
Create an Alembic migration
Generate these keys on user creation (similar to project keys)
Make ssh_key_pub in /runs/get_plan and /runs/apply optional and use new user keys in that case
Let CLI download the user's ssh_private_key and ssh_public_key if they are available - using user token hash as a part of the name; use previous logic if the user key can’t be downloaded - when both submitting the run and attaching to it
Backward-compatibility:
Ensure the new CLI can work with an old server (where User doesn't have ssh_private_key and ssh_public_key)
changed the title [-][Feature]: Allow a user to attach to runs from different machines[/-][+][Feature]: Store user SSH key on the server[/+]on Oct 9, 2025
Activity
github-actions commentedon Jan 3, 2025
This issue is stale because it has been open for 30 days with no activity.
peterschmidt85 commentedon Oct 8, 2025
Implementation plan:
ssh_private_keyandssh_public_keyproperties inUserin the databasessh_key_pubin/runs/get_planand/runs/applyoptional and use new user keys in that casessh_private_keyandssh_public_keyif they are available - using user token hash as a part of the name; use previous logic if the user key can’t be downloaded - when both submitting the run and attaching to itBackward-compatibility:
Userdoesn't havessh_private_keyandssh_public_key)peterschmidt85 commentedon Oct 8, 2025
@r4victor Please let me know if the plan above is OK to you
jvstme commentedon Oct 8, 2025
@peterschmidt85, 👍
Also preferably:
[-][Feature]: Allow a user to attach to runs from different machines[/-][+][Feature]: Store user SSH key on the server[/+][Feature]: Store user SSH key on the server #2053
[Feature]: Store user SSH key on the server #2053
[Feature]: Store user SSH key on the server #2053
[Feature]: Store user SSH key on the server #2053
[Feature]: Store user SSH key on the server #2053
[Feature]: Store user SSH key on the server (#3176)