Skip to content
Edith

Docs

Command reference

ed machines forwards add

Saves a port forward against a machine. It saves only; use on to open it.

Output
ed machines forwards add <machine> --local <n> --remote <n>                                   [--remote-host <h>] [--title <t>] [--json]

Arguments

Name Type / values Default What it does
<machine> string, required none Machine name, ssh alias, id or unambiguous prefix.

Options

Name Type / values Default What it does
--local integer 1 to 65535, required none Port to open on this Mac. Bound to 127.0.0.1, not to every interface.
--remote integer 1 to 65535, required none Port to reach on the far side.
--remote-host string localhost The host the far side should connect to, resolved on the machine. Point it at another box on that network to reach through.
--title string "" What to call it in the list.
--json flag off Emit JSON on stdout instead of the line.
--help, -h flag off Print the help for this command on stdout and exit 0.
Output
$ ed machines forwards add devbox --local 8080 --remote 80 --title "web"added 127.0.0.1:8080:localhost:80 on Devbox

--json shape

The same object forwards ls emits, with one difference worth knowing:

JSON
{  "id": "1E0B4C4A-5D3B-4F5B-9D2E-0F1A2B3C4D5E",  "index": 0,  "localPort": 8080,  "remoteHost": "localhost",  "remotePort": 80,  "spec": "127.0.0.1:8080:localhost:80",  "title": "web"}

index is 0 here, not the new row's position. The number is only meaningful in a listing, so run ed machines forwards ls <machine> --json afterwards if you need the position to pass to on.

Examples

Output
ed machines forwards add devbox --local 8080 --remote 80ed machines forwards add devbox --local 5433 --remote 5432 --title postgresed machines forwards add devbox --local 9000 --remote 9000 --remote-host 198.51.100.7

Behaviour notes

Appends to forwards.json and posts machinesChanged. Two forwards on one machine cannot claim the same local port:

Output
$ ed machines forwards add devbox --local 3000 --remote 3000error: Devbox already forwards local port 3000hint: run `ed machines forwards ls Devbox` to see them

That exits 1, as does a port outside 1 to 65535. The check is per machine, so two different machines may both save local port 3000; only one of them can have it open at a time, and the second on is what fails.

Where to go next