Skip to content
kylefritzPublic

About

SSH port forwarding for the macOS menu bar

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

fwd app icon

fwd

SSH port forwarding that lives in your menu bar.

Type 3000, get localhost:3000 from your dev box. No flags, no terminal tab to babysit.

Latest release CI macOS 26+ MIT license

Install · Using it · When fwd connects · Troubleshooting


fwd open from its menu bar icon: devbox forwarding web, api and a 42** range; gpu-box forwarding Jupyter; staging waiting for an ssh session

Why fwd

ssh -L 3000:localhost:3000 devbox works, until the laptop sleeps, the Wi-Fi changes, a second server starts on 3001, or something local already has 3000. fwd does the bookkeeping:

  • 🔌 Zero setup. Hosts come straight from ~/.ssh/config. If ssh devbox works in a terminal, it works in fwd, including ProxyJump, Cloudflare Access and hardware keys.
  • ✳️ Ranges. 3*** forwards whatever is listening from 3000 to 3999, and follows servers as they start and stop.
  • 🔀 Never "address already in use". If the laptop port is taken, fwd picks the next free one and shows you where it went.
  • 🟢 See what's alive. Each port shows whether a server is listening on the remote and whether a connection is open through it right now.
  • 🖥️ One-click Screen Sharing. Opens the remote's screen over the same ssh connection.
  • 🧑‍💻 One-click VS Code. Opens a Remote-SSH window on the host in VS Code, or from the terminal with fwd code devbox. If the host runs herdr, the button also lists its agents, each in the folder or worktree it's working in, and the repos and worktrees they use, so you can open one directly.
  • 🤝 Polite. fwd connects while you're ssh'd into a host, or when you ask it to. It doesn't dial out on its own unless you pin a port to stay connected.

Install

Note

Needs macOS 26 or later on Apple Silicon, and ssh keys that log in without a prompt (in the agent or the keychain). fwd never asks for passwords.

Homebrew (recommended)

brew install kylefritz/tap/fwd

Homebrew installs the app from the release, already built, so there's nothing to compile and no Gatekeeper step. Update with brew upgrade fwd; the app tells you when there's a new version.

Download

Grab fwd.zip from the latest release, unzip it, drag fwd.app into /Applications, then run:

xattr -dr com.apple.quarantine /Applications/fwd.app

fwd isn't notarized by Apple, so without that line macOS says it "could not verify fwd is free of malware" the first time you open it. (Clicking Open Anyway in System Settings → Privacy & Security works too.) After that, a downloaded copy updates itself: it fetches new versions in the background and offers Restart to update.

Build from source

Needs only Apple's Command Line Tools (xcode-select --install).

git clone https://github.com/kylefritz/fwd && cd fwd
make install   # builds, copies fwd.app to /Applications, links ~/.local/bin/fwd

A source build reports version dev, shows the commit it was built from at the bottom of the panel, and doesn't update itself.

Using it

Click the fwd icon in the menu bar. Every host in your ssh config gets a card; type a port into its field and press Return.

You type You get
3000 remote 3000 on localhost:3000
3000 -> 4000 remote 3000 on localhost:4000
31** every listening remote port from 3100 to 3199, same numbers locally
3*** -> 4*** every listening remote port from 3000 to 3999, shifted to 4000 to 4999
3000 api the same, labelled api

* stands for one digit and goes at the end. The left side is always the remote port. Local ports below 1024 aren't allowed (80 -> 8080 is fine).

Each entry becomes a pill. Click it to turn it off or on, click the arrow to open it in your browser, and right-click for Keep connected, Rename…, Copy localhost:… and Remove.

Pill Meaning
◌ dashed circle off
○ hollow circle forwarded, nothing listening on the remote yet
🟢 green circle a server is listening on the remote
⚡ green bolt a connection is open through it right now
📌 pin kept connected
⚠️ orange triangle blocked; hover for the reason
↳ orange bent arrow your laptop port was taken, so it moved to the one shown

Opening forwards by name

Choose Open Forwards by Name… in the ••• menu and click Turn On. A forward named web then opens at http://web.localhost, with no port number. It works in any browser that resolves .localhost names, and there's no password and nothing to install.

fwd does this by listening on port 80 and passing each connection to the forward it names. It refuses connections from other computers. macOS only lets an app without root listen on port 80 on every network interface, so fwd checks each connection and closes any that doesn't come from your Mac. Turn Off in the same window stops it. While fwd isn't running, these addresses show a browser error.

Forward name.localhost shows
Up your app
Off a page with Turn On
On, host not connected a page with Connect
Connected, nothing listening a page that reloads when your app comes up
Name on two hosts a list of links; each is name.host.localhost

Only a click connects a host: loading the address never does, and other websites can't press those buttons for you. Only named forwards on a single port get an address, so ranges and Screen Sharing don't. https:// doesn't work.

If two forwards on a host end up with the same address, like my api and my-api, the lower port keeps it and the window asks you to rename the other.

Screen Sharing

Click the display icon on a host card. fwd forwards the remote's port 5900 to localhost:5901 (5902 for the next host, and so on) and opens it in macOS's Screen Sharing app with your ssh user name filled in. When you close the viewer, fwd turns the forward off again. The remote needs Screen Sharing on (System Settings → General → Sharing) or any VNC server on 5900.

From the terminal

The fwd command does what the panel does, so you, scripts and coding agents can forward ports without clicking:

fwd devbox 3000           # forward devbox:3000, print http://localhost:3000
fwd 3000                  # the same, when devbox is the one connected host
fwd 3000 5173 web --keep  # several ports, with a name, kept connected
fwd wait 3000             # block until a server answers on devbox:3000
fwd status                # hosts and ports with their live state
fwd off 3000              # turn it off; fwd remove 3000 forgets it
fwd guard devbox          # other programs' ssh can't open devbox's sign-in page
fwd open                  # open the window

Tell your agent about fwd

Coding agents won't know fwd exists unless you tell them. Paste this into your agent's instructions (~/.claude/CLAUDE.md, a project's AGENTS.md), or run fwd agents to print it:

## fwd: reaching servers on remote hosts

fwd forwards ports from ssh hosts to this Mac. Use it when something you
run here (a browser, curl, tests) needs a server on a remote host.

- `fwd <host> <port> --wait --json` forwards the port and waits until a
  server answers. The local URL is in `host.ports[0].url`; it can be a
  different local port than the remote one.
- `fwd status --json` lists hosts, their state and forwarded ports with
  URLs. Check it instead of guessing ports.
- `fwd <host> <port> --json` forwards without waiting (state `waiting`
  means nothing listens on the remote yet); `fwd wait <host> <port>`
  waits later.
- `fwd off <host> <port>` turns a forward off when you're done.
- The host can be left out when exactly one host is connected.
- Exit codes: 0 done, 1 couldn't (read `error`), 2 bad usage, 3 the fwd
  app isn't reachable, 4 timed out.
- An `error` saying a host "needs you" means it is waiting for a person (a
  browser sign-in, a key). Tell them and stop: running the command again
  won't connect it.
- Don't add `--keep` unless asked: it keeps the host connected after
  the session that started it ends.
- `fwd --help` lists everything.

To see what has been running fwd, choose Command Line Activity… in the ••• menu. It lists each command with how often it ran and the programs that ran it, so a script or agent stuck in a loop is one row with a high count. The log names the caller too: cli: forward devbox 3000 (from zsh ← node ← launchd).

The command starts fwd if it isn't running. Homebrew installs it; otherwise choose Install Terminal Command in the ••• menu.

When fwd connects

fwd holds a connection to a host only when something asks for one:

Reason Reconnects after a drop, sleep or network change?
You have ssh <host> open in a terminal ✅ as long as your session lasts
A port on the host is set to Keep connected 📌 ✅ always
You clicked: turned a port on, Screen Sharing, Connect ❌ connects once

Otherwise the card says Not connected · starts when you ssh in and offers Connect. That way fwd never keeps knocking on a machine you've stopped using, and never opens a sign-in page behind your back.

To make fwd leave a host alone entirely, choose Turn Off and Hide in the host's ••• menu. fwd drops its connection and won't connect it for any reason: not your ssh sessions, not a kept port, not the fwd command. The host moves to Hidden hosts at the bottom of the panel, with its ports kept as they were, and Turn On brings it back.

  • A dead link is noticed within about 15 seconds. Retries come after 2, 5, 15 and 30 seconds, then once a minute.
  • Asleep or offline, fwd does nothing at all, and picks up again when the Mac wakes or the network returns.
  • A sign-in page (from a proxy like cloudflared) opens only when you ask: Connect, Sign In, turning a port on, or fwd connect <host>. fwd then waits up to three minutes for you to sign in and connects by itself. A connection nobody asked for (a reconnect, a kept port, your ssh session, a script running fwd <host> <port>) never opens one: the host shows Sign In and waits for you.
  • When ssh needs a person (key not loaded, unknown host key, a browser sign-in), fwd stops and shows Retry or Sign In, and Open in Terminal. Only those or fwd connect <host> try again: running fwd <host> <port> once more doesn't.
  • If another program keeps starting ssh <host> through a sign-in proxy (three or more tries in ten minutes that don't last), the card says so and names what started them. Each of those can open a sign-in tab; they aren't fwd's, and they stop once you've signed in. Guard on that card stops the tabs (see below).

Guarding a host's sign-in page

A program that checks a host in the background (a terminal multiplexer with a saved machine, an editor's remote extension) runs ssh <host> again and again. If the host signs in through a browser and the sign-in has run out, every one of those opens a tab. Leave the laptop for a weekend and there are hundreds.

Guard the host and only fwd's Sign In button opens its sign-in page: click Guard when the card warns you, choose Guard Its Sign-in Page in the host's ••• menu, or run fwd guard devbox. A guarded host shows a small shield on its card, and the log counts the pages it kept from opening.

What it changes:

  • One Include line at the top of your ~/.ssh/config, naming ~/.config/fwd/ssh-guard.conf. Your own Host blocks aren't edited.
  • That file gets a block for the host that runs its own ProxyCommand with a do-nothing open first on PATH. The proxy still connects when the sign-in is good; it just can't open the browser.
  • An ssh run with FWD_UNGUARDED=1 skips the block, so FWD_UNGUARDED=1 ssh devbox in a terminal opens the page as before. fwd's own connections and Open in Terminal do this for you.

fwd guard devbox --off or Stop Guarding Its Sign-in Page takes the block out, and the Include line with it once no host is guarded. If the host's ProxyCommand changes, fwd rewrites the block to match. fwd can't guard a ProxyCommand that is a pipeline or starts with a shell word like exec; it says so and leaves the config alone.

Configuration

Everything lives in plain files, so it's easy to keep in your dotfiles.

File What it is
~/.config/fwd/ports.yaml Your entries. Edit by hand if you like; changes apply within a second.
~/.config/fwd/config.yaml Preferences: check_for_updates: false turns off update checks, send_usage_stats: false keeps them but stops the install count, update_channel: beta follows every build of main, herdr: false makes the VS Code button open VS Code at once instead of listing herdr's agents and folders.
~/.config/fwd/state.yaml Laptop ports fwd chose when yours were taken, and the hosts you turned off. Safe to delete: turned-off hosts come back on.
~/.config/fwd/ssh-guard.conf Written by fwd for guarded hosts; your ssh config includes it. Turn guards off in fwd instead of editing it.
~/Library/Logs/fwd/fwd.log The log. Show Log in the ••• menu opens it; hold ⌥ for Copy Log Location.
# ~/.config/fwd/ports.yaml
hosts:
  devbox:
    - port: "5173"
      name: web
      keep: true        # stay connected without an ssh session
    - port: "3*** -> 4***"
      on: false

If ports.yaml can't be parsed, fwd says so, keeps running on the last good version and leaves your file alone. Comments are lost when fwd saves the file.

Trying a pull request

Each pull request gets a preview build. fwd try 42 swaps the app for pull request #42's build and restarts it; the footer shows PR #42 while it runs. fwd try beta or fwd try stable goes back. A preview counts as the newest beta, so on the beta channel the next build of main replaces it as usual. This works for the downloaded app; a Homebrew copy can't switch builds.

Troubleshooting

A host says "needs attention"

Click Open in Terminal, finish whatever ssh asks for (load a key, accept a host key, sign in), then click Retry.

A host says "Not connected · starts when you ssh in"

That's expected: nothing asked for a connection. ssh into the host, click Connect, or right-click a port and choose Keep connected.

A range says it can't scan the host

The remote has none of ss, netstat or lsof. Single ports still work.

A port shows a bent arrow

Something on your Mac already had that port. Turn the entry off and on to try the original port again.

Open Forwards by Name says port 80 is in use

Another web server on your Mac has it. Stop that server, then click Try Again. Until then web.localhost:8765 still works with the port number.

Anything else

Choose Report a Bug… in the ••• menu. Pick how much of the log to include, check the preview, and fwd opens a prefilled GitHub issue. Sign-in tokens, IP addresses and your home folder are always removed, and host names can be. A log too long for the link is copied and opened in a text editor, for you to paste into the issue's Log field. tail -f ~/Library/Logs/fwd/fwd.log shows what fwd is doing as it happens.

How it works

fwd drives the system ssh: one background ControlMaster connection per host, with forwards added and removed on it as needed. Your ssh config applies exactly as it does in a terminal. A small POSIX script run over the same connection lists the remote's listening ports, and fwd reconciles the forwards against it every few seconds.

Privacy. fwd talks to your hosts over ssh and asks GitHub whether there's a new release. With each of those update checks it also sends a small ping to fwd.kylefritz.co so I can count installs: a random install ID, the version, the update channel, how fwd was installed and the macOS version, plus your IP address as the request arrives. Nothing else leaves your Mac. send_usage_stats: false stops the ping; check_for_updates: false stops both. The ping is write-only: updates never depend on it. They come over HTTPS from this repository and are checked for the right bundle, version and code signature before they're offered; they aren't signed with an Apple Developer ID.

Development

make test   # unit tests, plus end-to-end tests against a throwaway local sshd
make app    # build/fwd.app

The tests start their own OpenSSH server on 127.0.0.1 as you, with keys in a temporary folder. No Docker, no root. Design notes live in docs/spec.md.

License

MIT

About

SSH port forwarding for the macOS menu bar

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages