Skip to content
Console

CLI: Ports, SSH & Exec

Manage locked public ports, access keys, local port forwarding, one-time SSH logins, live watched folders, remote command execution, and pod or task logs in the meshive CLI.

Connecting to running Pods, managing locked ports and access keys, executing remote commands, configuring watched folders, and reading logs with the meshive CLI. See Pods & Lifecycle for listing, starting, stopping, and deleting Pods.

From 1.10, a pod’s public ports can be locked: only workspace members signed in to the console, and programs that send one of the port’s access keys, get through. pod-create locks new public ports by default, and pod-update locks the ports it newly makes public; pass --no-lock to leave them open to anyone with the URL, as before 1.10. Ports that are public already keep their lock unless you name them.

Terminal window
meshive port-lock <workspace> <pod> <port> # lock a public port, no restart
meshive port-unlock <workspace> <pod> <port> # open it to anyone with the URL (asks first)
meshive port-keys <workspace> <pod> <port> # the port's keys: names and first characters only
meshive port-key-create <workspace> <pod> <port> --name <label> [--expires 30|90|365]
meshive port-key-roll <workspace> <pod> <port> <key-id> [--overlap now|1h|24h|7d]
meshive port-key-revoke <workspace> <pod> <port> <key-id>
meshive port-preflight <workspace> <pod> <port> on|off # let CORS preflight requests reach the app without a key
meshive pod-browser-sessions-revoke <workspace> <pod> # sign out browser sessions on the pod's locked ports (asks first)
meshive workspace-browser-sessions-revoke <workspace> # the same for every pod in the workspace (asks first)
CommandWhat it does
port-lockLocks a public port. It only adds protection, so it doesn’t ask. Programs that call the port without a key get 401 from then on. It waits up to 60 seconds until the lock is confirmed and exits with code 1 if it isn’t; --no-wait returns at once with code 0.
port-unlockUnlocks a port, after asking. The port’s access keys are kept and work again when it is locked again. Waits and exits like port-lock.
port-keysLists the keys that work now: ID, NAME, the first characters of the KEY, EXPIRES, LAST USED (for example 2 hours ago, or never; it is updated every few minutes and shown when the server reports it), ISSUED BY, and OLD VALUE WORKS UNTIL after a roll. Works with a read-only key. A key’s value is never listed.
port-key-createCreates a key for a locked port and prints its value once. --name is required. --expires is 30, 90 (default) or 365 days. -o name prints only the value, for KEY=$(meshive port-key-create … -o name).
port-key-rollGives a key a new value, printed once, and keeps the old value working for --overlap (default 1h; now stops it at once). Asks first, because clients using the old value stop working.
port-key-revokeRevokes a key, after asking. It stops working within seconds.
port-preflightmeshive port-preflight <workspace> <pod> <port> on|off. on lets CORS preflight (OPTIONS) requests to a locked port reach your app without a key; off (the default) refuses them like any request without a key. on asks first. See Allow preflight.
pod-browser-sessions-revokemeshive pod-browser-sessions-revoke <workspace> <pod>. Signs out the browser sessions on the pod’s locked ports, after asking. Access keys and open connections are not affected. See Browser sessions.
workspace-browser-sessions-revokemeshive workspace-browser-sessions-revoke <workspace>. Signs out the browser sessions on the locked ports of every pod in the workspace, after asking. Access keys and open connections are not affected. See Every Pod in a workspace.

<port> is the port number as meshive pod lists it, and <key-id> the ID from port-keys. Locking, unlocking and creating, rolling or revoking keys need a Read & write key of an admin or billing member of the workspace. For an app that can’t send a key, see meshive port-forward.

port-key-create and port-key-roll are not sent again after a timeout, because each request issues a new value. If one ends without an answer, check meshive port-keys before running it again; a key whose value you don’t have can be revoked.

When the server can’t lock ports right now, pod-create and pod-update change nothing and say so. Run them again later, or with --no-lock (or --unlock-port <port> for one port) to go ahead with open ports. The CLI never falls back to open ports by itself.

For an app that takes only an address and can’t add a header to its requests — a desktop client, an IDE plugin, a browser extension — meshive port-forward runs a small forwarder on your computer. It listens on http://127.0.0.1:<port>, adds the port’s access key to every request and passes the request on to the locked port. WebSockets work too. Point the app at the local address, and leave the command running while you use it.

Terminal window
# macOS, Linux, Git Bash
export MESHIVE_ACCESS_KEY="mshv_..." # one of this port's keys
meshive port-forward <workspace> <pod> <port>
Terminal window
# Windows PowerShell
$env:MESHIVE_ACCESS_KEY = "mshv_..."
meshive port-forward <workspace> <pod> <port>

The command prints the local address, for example Forwarding http://127.0.0.1:8188 → https://…. Open it in a browser or give it to the app. Press Ctrl+C to stop.

OptionWhat it does
--listen PORTThe local port to listen on. The default is the same number as the pod’s port, so an app that expects 127.0.0.1:8188 just works. 0 picks a free port. If the port is in use, the command says so and exits.
--key-file PATHReads the key from a file instead of MESHIVE_ACCESS_KEY. The file holds only the key. It wins over the environment variable.
--allow-origin ORIGINLets pages from one more address, such as http://localhost:3000, send requests through the forwarder. Repeat it for more.
-v, --verbosePrints one line per request: method, path and status. Never the query string or the key.

<port> is the port number as meshive pod lists it. The key comes only from the environment variable or --key-file, never from the command line, so it doesn’t end up in your shell history or in the list of running programs. Create a key with meshive port-key-create; meshive port-forward uses your Meshive API key once, at the start, to look up the port’s address, and a read-only key is enough. A port that isn’t locked needs no key.

What it protects, and what it doesn’t:

  • It answers only on 127.0.0.1, never on your network.
  • It refuses requests made by web pages on other sites, so a page you happen to have open can’t use your key through it.
  • Other programs on your computer can use it without a key — anything that can connect to 127.0.0.1 reaches the port through it. Run it only on a computer you trust, and stop it when you are done.
  • Revoking the key doesn’t close a connection that is already open.

Prints a one-time SSH command and password for a pod — the same login as the console’s Connect tab. It doesn’t run ssh for you. It needs a read & write key.

Terminal window
meshive ssh <workspace> <pod>

The password expires after a few minutes, and each run issues a new one. The output also has a browser-terminal link with the password in it, so don’t paste it anywhere shared.

Shows or changes a running pod’s watched folders — folders whose new files are uploaded as assets — without restarting it.

Terminal window
meshive pod-watch <workspace> <pod> # list them
meshive pod-watch <workspace> <pod> --add /workspace/results --include '*.csv' [--existing] [-y]
meshive pod-watch <workspace> <pod> --off /workspace/outputs # template folders can be turned off
meshive pod-watch <workspace> <pod> --remove /workspace/results

Adding or turning on a folder asks for confirmation because uploaded files are stored and billed; --existing also uploads the files already there. Removing or turning off applies at once. A folder on network storage can’t be watched, and a pod that is being created or changed can’t be edited until that finishes — the command prints the server’s reason.

Run a command in a running Pod (CLI 1.9 or later). It needs a Read & write key and an admin or billing role in the workspace. The command runs immediately; it does not show a resource estimate or confirmation prompt.

Terminal window
meshive pod-exec --max-seconds 20 WORKSPACE POD -- pwd
meshive pod-exec --background WORKSPACE POD -- "python train.py"

Put the command after --. A single quoted argument preserves shell pipes and redirection. Put global flags such as -o json before the workspace; --background and --max-seconds may also appear after the Pod and before --.

Foreground execution waits up to --max-seconds (1–25, default 20), prints the captured output and returns the command’s exit code. A timeout returns 124. Output is capped at about 64 KiB; if it is truncated and the remote exit code is unknown, the CLI returns 1. Use --background for longer work. It prints a run ID, output path and a command you can choose to use to stop the run.

A retry can execute the command again. Check the Pod first if an earlier request may have started it.

Read a background command’s state, exit code and last output lines with the same Read & write key:

Terminal window
meshive pod-exec-status WORKSPACE POD RUN_ID --tail 100
meshive pod-exec-status WORKSPACE POD RUN_ID --wait --interval 10

--tail accepts 1–1,000 lines. --wait keeps checking until the command ends and returns its exit code; --interval controls the delay between checks. A Pod restart removes its command runs.

Terminal window
meshive logs <workspace> <pod> [--tail 200] [--container <name>] [--wait <s>]
meshive task-logs <id> [--tail 200] [--wait <s>] [--cursor <n>]

Prints the last --tail lines (up to 1000) of a pod’s or a task’s logs — a snapshot, not a stream. If nothing is buffered yet, or nobody has been watching the pod, the server starts a log watcher and waits up to --wait seconds (default 8) before answering; with --wait 0 it answers from the buffer and notes when those lines may be behind. Output is capped at 64 KiB; a truncated note on stderr says when older lines were dropped. -o json returns the lines with timestamps. For tasks running on an external provider, task-logs prints the last lines by default and --cursor <n> (the next_cursor of a previous -o json result) prints only the lines after it.