Skip to content

Gateway restart regenerates TLS certificates, breaking existing sandbox connections #888

Closed

Description

@GarfieldHuang

Problem

When the OpenShell gateway restarts (e.g., after openshell gateway start or system reboot), it regenerates its mTLS CA keypair. Existing sandbox pods still hold the old gateway CA certificate, so every subsequent connection attempt fails with:

[WARN] SSH connection: handshake verification failed

The only workaround is to destroy and recreate all sandboxes via nemoclaw onboard, which is disruptive and loses sandbox state.

Steps to Reproduce

  1. Create a sandbox: nemoclaw onboard
  2. Restart the gateway: openshell gateway start (after a stop or system reboot)
  3. Try to connect: nemoclaw <name> connect
  4. Connection fails with Command failed (exit 255)

Expected Behavior

Gateway restart should not invalidate existing sandbox connections. Options:

  • Persist the gateway CA keypair to a PersistentVolume so it survives restarts
  • Implement a certificate rotation mechanism where sandboxes can fetch the new gateway CA cert automatically

Environment

  • NemoClaw CLI / openshell 0.0.12
  • WSL2 Ubuntu on Windows 11
  • k3s (via Docker Desktop)

Activity

  1. rafaelluna commented on Mar 27, 2026

    @rafaelluna

    I have the same issue every time my computer restarts. The onboarding process just wipes the whole configuration.

  2. salmanadil84 commented on Mar 29, 2026

    @salmanadil84

    I'm having the same problem. Every time my computer or gateway restarts, I have to onboard again, and I lose all my settings and configuration.

  3. dknos commented on Mar 30, 2026

    @dknos
    Contributor

    Workaround: always regenerate SSH config fresh — don't cache it

    The TLS cert rotation breaks any cached SSH configs. The fix is to never persist openshell sandbox ssh-config output — regenerate it fresh on every connection attempt.

    In any script that SSHes into the sandbox:

    # Generate fresh SSH config each time — never cache this
    SSH_CONF=$(mktemp /tmp/nemoclaw-XXXXXX.conf)
    openshell sandbox ssh-config "$SANDBOX" > "$SSH_CONF"
    ssh -T -F "$SSH_CONF" "openshell-${SANDBOX}" "your-command"
    rm -f "$SSH_CONF"

    This handles cert rotation transparently — ssh-config always returns the current valid config reflecting the new certificates. We call this at the top of every startup script and every SSH exec, so cert rotation after a gateway restart is never a problem.

    Also helps: run openshell sandbox ssh-config as a health check before attempting anything. If it returns empty or errors, the gateway isn't ready yet — retry with backoff rather than failing.

  4. self-assigned this
    on Apr 1, 2026
  5. ericksoa commented on Apr 5, 2026

    @ericksoa
    Member

    This should be resolved by OpenShell #753, which persists sandbox state across gateway stop/start cycles. We'll close this issue once that lands and we validate it fixes the cert mismatch.

  6. removed their assignment
    on Apr 6, 2026
  7. dknos commented on Apr 9, 2026

    @dknos
    Contributor

    Additional root cause found: NSSH1 handshake secret mismatch in Sandbox CR

    Beyond the TLS cert rotation, there's a separate failure mode: the gateway regenerates its OPENSHELL_SSH_HANDSHAKE_SECRET on restart, but the Sandbox custom resource (CR) retains the stale secret. This causes kex_exchange_identification: Connection closed by remote host even after the pod is bounced, because the CR templates the pod spec with the old value.

    Workaround (tested on v0.0.14 gateway, helm release v4):

    1. Read the gateway's current secret: kubectl exec openshell-0 -n openshell -- printenv OPENSHELL_SSH_HANDSHAKE_SECRET
    2. Patch the Sandbox CR with the new value: kubectl get sandbox my-assistant -n openshell -o json → replace the secret → kubectl apply -f -
    3. Delete the sandbox pod to force recreation with the patched CR

    This could be automated in nemoclaw onboard or a startup script. We've added it to our 1-click startup to auto-detect and fix the mismatch.

  8. self-assigned this
    on Apr 16, 2026
  9. ericksoa commented on May 1, 2026

    @ericksoa
    Member

    Closing this as fixed for current supported NemoClaw/OpenShell versions.

    Fixing PR chain:

    The remaining legacy caveat is documented: sandboxes created with OpenShell versions older than 0.0.24 may need OpenShell upgrade plus sandbox recreation. Current latest installs a newer validated OpenShell, and the sandbox-survival E2E explicitly covers this issue (#888/#1086).

  10. added
    area: sandboxOpenShell sandbox lifecycle, runtime, config, or recovery
    and removed on Jun 3, 2026
  11. added theissue type on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: sandboxOpenShell sandbox lifecycle, runtime, config, or recovery

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions