Skip to content

Commit c8d33de

Browse files
fix(ssh): persist sandbox host identities (ai-openshell/openshell#4094)
* fix(ssh): persist sandbox host identities Store each sandbox's Ed25519 host key in the gateway credential store and deliver it only to the supervisor. Preserve identity across restarts, delete owned credentials with the sandbox, and expose the public SHA256 fingerprint through sandbox and SSH-session APIs and client SDKs. Cover credential ownership, cancellation, deletion retries, client compatibility, and pinned SSH connections through lifecycle transitions. Closes ai-openshell/openshell#3835 Signed-off-by: Mike Nguyen <miken@nvidia.com> * fix(compute): clean up failed sandbox SSH identity creation Signed-off-by: Mike Nguyen <miken@nvidia.com> * test(ssh): wait for sandbox deletion before name reuse Signed-off-by: Mike Nguyen <miken@nvidia.com> --------- Signed-off-by: Mike Nguyen <miken@nvidia.com>
1 parent 7c5596c commit c8d33de

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/openshell/sandbox.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ class SandboxRef:
521521
service_urls: Mapping[str, str] = field(
522522
default_factory=_ImmutableLabels, compare=False
523523
)
524+
# Stable SSH host identity; absent on older runtimes.
525+
host_key_fingerprint: str | None = None
524526

525527
def __post_init__(self) -> None:
526528
object.__setattr__(self, "labels", _ImmutableLabels(self.labels))
@@ -1796,6 +1798,7 @@ def _sandbox_ref(
17961798
labels=sandbox.metadata.labels if sandbox.metadata else {},
17971799
created_from_workload_template=provenance,
17981800
service_urls=service_urls or {},
1801+
host_key_fingerprint=sandbox.host_key_fingerprint or None,
17991802
)
18001803

18011804

‎tests/sandbox_test.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,13 @@ def test_sandbox_ref_retains_gateway_labels() -> None:
27282728
assert dict(ref.labels) == {"aiq": "deep-research", "env": "dev"}
27292729

27302730

2731+
def test_sandbox_ref_exposes_host_identity_and_accepts_legacy_response() -> None:
2732+
proto = _make_sandbox_proto("sandbox-1", "job-1")
2733+
assert _sandbox_ref(proto).host_key_fingerprint is None
2734+
proto.host_key_fingerprint = "SHA256:expected"
2735+
assert _sandbox_ref(proto).host_key_fingerprint == "SHA256:expected"
2736+
2737+
27312738
def test_sandbox_ref_includes_main_process_result() -> None:
27322739
proto = _make_sandbox_proto("sandbox-1", "job-1")
27332740
proto.status.exit_code = 0

0 commit comments

Comments
 (0)