Last active
June 5, 2026 18:36
-
-
Save josephschmitt/e81575df85b9903609ecba067454f8b8 to your computer and use it in GitHub Desktop.
Crafting ssh proxy commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Resolve a friendly sandbox hostname to the real Crafting SSH proxy hostname. | |
| # Usage: cs-ssh-proxy-wrapper <hostname> | |
| # cs-ssh-proxy-wrapper joebox.crafting -> uses first workspace | |
| # cs-ssh-proxy-wrapper uc-frontend--joe-fe.crafting -> uses specified workspace | |
| CS=$(command -v cs) | |
| NAME="${1%%.*}" | |
| # Support optional workspace: workspace--sandbox | |
| case "$NAME" in | |
| *--*) | |
| WORKSPACE="${NAME%%--*}" | |
| SANDBOX="${NAME#*--}" | |
| ;; | |
| *) | |
| WORKSPACE="" | |
| SANDBOX="$NAME" | |
| ;; | |
| esac | |
| INFO=$(TERM=dumb "$CS" sandbox list -o json --suppress-notifications 2>/dev/null | \ | |
| jq -r --arg name "$SANDBOX" '.[] | select(.meta.name == $name) | "\(.meta.id) \(.spec.workloads[0].name // "app") \(.status.sandbox.lifecycle_stage // "UNKNOWN")"') | |
| if [ -z "$INFO" ]; then | |
| echo "Error: could not resolve sandbox '$SANDBOX'" >&2 | |
| exit 1 | |
| fi | |
| SANDBOX_ID="${INFO%% *}" | |
| REST="${INFO#* }" | |
| DEFAULT_WORKSPACE="${REST%% *}" | |
| STATE="${REST#* }" | |
| if [ -z "$WORKSPACE" ]; then | |
| WORKSPACE="$DEFAULT_WORKSPACE" | |
| fi | |
| if [ "$STATE" = "SUSPENDED" ] || [ "$STATE" = "SUSPENDING" ]; then | |
| "$CS" sandbox resume "$SANDBOX" --suppress-notifications >&2 | |
| fi | |
| REAL_HOST="${WORKSPACE}--${SANDBOX_ID}-compass.sandbox.compass.com" | |
| exec "$CS" ssh-proxy "${REAL_HOST}:443" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Host *.sandbox | |
| ProxyCommand sh -c 'cs-ssh-proxy-wrapper %h' | |
| UserKnownHostsFile /Users/josephschmitt/.crafting/sandbox/known_hosts | |
| User owner | |
| StrictHostKeyChecking no | |
| HashKnownHosts no | |
| IdentityFile /Users/josephschmitt/.crafting/sandbox/id_client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment