Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jvstme
Copy link
Collaborator

@jvstme jvstme commented Oct 22, 2025

This commit updates the CLI and the server to use
server-managed user SSH keys when starting new
runs. This allows users to attach to the run from
different machines, since the SSH key is
automatically replicated to all clients.

Implementation details:

  • Server:
    • If the user key is missing, generate it when the user first calls /get_my_user.
  • Client:
    • Before applying or getting a run plan, call /get_my_user to check if the user key is available. If it is, use it.
    • Cache the downloaded keys in ~/.dstack/ssh to avoid repeated /get_my_user calls.
    • Switch from warn to logger messages, since this code is part of the Python API, so its output should be configurable.

Closes #3199

This commit updates the CLI and the server to use
server-managed user SSH keys when starting new
runs. This allows users to attach to the run from
different machines, since the SSH key is
automatically replicated to all clients.

Implementation details:
- Server:
    - If the user key is missing, generate it when
      the user first calls `/get_my_user`.
- Client:
    - Before applying or getting a run plan, call
      `/get_my_user` to check if the user key is
      available. If it is, use it.
    - Cache the downloaded keys in `~/.dstack/ssh`
      to avoid repeated `/get_my_user` calls.
    - Switch from `warn` to logger messages, since
      this code is part of the Python API, so its
      output should be configurable.
@jvstme jvstme requested a review from peterschmidt85 October 22, 2025 20:37
@jvstme jvstme merged commit 44c46ea into master Oct 23, 2025
28 checks passed
@jvstme jvstme deleted the issue_3199_use_user_ssh_keys branch October 23, 2025 08:43
from dstack._internal.core.models.users import UserWithCreds

if TYPE_CHECKING:
from dstack.api.server import APIClient
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why put UserSSHKeyManager in core instead of api?

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.

[Feature]: Use the user's SSH key in dstack CLI

2 participants