Mohamed Ali Mejbar
FR Fès Book a call
Contents
  1. 01 Work
  2. 02 Method
  3. 03 Prices
  4. 04 About
Book a call ali@mejbar.com It's in Fès.
← The notebook Terminal · Tailscale September 2026 · 12 min

A reproducible remote workspace with Zellij

A macOS development host, resilient SSH/Mosh sessions, and private HTTPS previews over Tailscale.

Written by .

I use a Mac mini as my development host and connect from a laptop or tablet when I am away from its keyboard. The useful boundary is simple:

  • SSH or Mosh transports my terminal to the Mac.
  • Zellij keeps a terminal session and its still-running processes on the Mac when my client disconnects.
  • Tailscale Serve makes one local development port available over HTTPS to devices on the same tailnet.

These are separate failure domains in the setup I rely on. A Mosh connection can recover after the host wakes, but it cannot keep a process alive through a Mac reboot. Tailscale Serve can retain its configuration across a reboot, but the development server behind it must be started again. I therefore treat Zellij as the process boundary, not as a promise that the whole machine is immortal.

I keep the real host configuration under ~/.config/zellij and use a small optional picker at ~/.local/bin/zpick when I want to attach to or create a session by name. Neither is required for the commands below: the explicit SSH/Mosh commands and the supplied layout are the reproducible baseline. The picker only saves keystrokes around the same zellij attach --create operation.

Prerequisites and the host/client split

The always-on host needs:

  • macOS with Remote Login (SSH) enabled in System Settings;
  • Tailscale logged into the tailnet;
  • Zellij, Mosh, and optionally fzf installed.

The client needs an SSH client and Mosh if you want Mosh. It does not need Zellij: the Zellij server and its panes run on the Mac. Install Tailscale on the host from the official download page (or use the Homebrew cask below), sign in, and install the remaining command-line tools on a Homebrew-managed Mac host with:

brew install --cask tailscale
brew install zellij mosh fzf

The cask is an alternative to downloading the app directly; use one of those two installation methods, not both.

Install Mosh on each client that will use it. On an iPad or phone, use an SSH client that supports Mosh; the app still connects to the same host and user. Tailscale must be connected on both devices.

On the host, verify the actual installation and the remote login before starting a session:

command -v zellij mosh tailscale fzf
zellij --version
mosh --version
tailscale version
tailscale status

From a client, first prove that SSH works over the tailnet:

ssh <mac-user>@<mac-magicdns-name>

Replace the angle-bracket values with the macOS account and the MagicDNS name shown by tailscale status; they are not shell variables. Mosh bootstraps through SSH, then uses a UDP connection. The Mosh usage documentation describes the SSH bootstrap and the server UDP port range. A host firewall must allow that Mosh traffic on the tailnet interface. If a network blocks Mosh’s UDP range, use SSH instead.

Connect with a real terminal

The most explicit first connection is SSH followed by Zellij:

ssh -t <mac-user>@<mac-magicdns-name> \
  'zellij attach --create dev'

The -t is important: Zellij needs a pseudo-terminal. attach --create attaches to dev if it exists and creates it if it does not. Create a project-specific session the same way:

ssh -t <mac-user>@<mac-magicdns-name> \
  'zellij attach --create myapp'

For Mosh, use the command separator so Mosh starts Zellij on the remote host:

mosh <mac-user>@<mac-magicdns-name> -- \
  zellij attach --create myapp

Remote commands frequently receive a smaller PATH than an interactive login. There are two lookups to fix: SSH must find mosh-server before Mosh can run the command, then that command must find Zellij.

The same lookup problem applies to ssh -t host 'zellij …'. If it cannot find Zellij, replace zellij in that remote command with the absolute host-side path reported by command -v zellij (for example, /opt/homebrew/bin/zellij on an Apple-silicon Homebrew host). -t allocates a terminal; it does not fix the remote PATH.

First run this on the Mac:

command -v mosh-server
command -v zellij
command -v fzf

For an Apple-silicon Homebrew installation whose first lookup returns /opt/homebrew/bin/mosh-server, connect from the client with:

mosh --server=/opt/homebrew/bin/mosh-server <mac-user>@<mac-magicdns-name> -- \
  zsh -lc 'export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$HOME/.local/bin:$PATH"; exec zellij attach --create myapp'

Use the actual host-side paths on an Intel Mac or a different installation. The --server option fixes Mosh’s bootstrap; the later PATH export cannot fix a server that never started. zsh -lc also does not imply that .zshrc has been sourced. Mosh’s official usage notes document this non-default-server-path case.

Attach, detach, and create sessions

Once connected, inspect sessions on the host:

zellij list-sessions --short

With the compact locked keymap below, press Ctrl-g to enter normal mode, then o for the session mode and d to detach. Detaching leaves the Zellij server and every process in the panes running on the Mac. Closing a terminal, losing Wi-Fi, or switching from Wi-Fi to cellular is also a disconnect, not a request to terminate those processes.

Attach again later with:

zellij attach myapp

Use a new name with zellij attach --create name. A new name creates a new session; it does not clone a layout or attach to the closest existing project. To intentionally terminate a session, use its exact name:

zellij kill-session myapp

kill-session is different from detaching and is not a recovery step.

If you installed fzf, select a session without memorizing its name:

session="$(zellij list-sessions --short --no-formatting | fzf --prompt='Session> ')" &&
  zellij attach "$session"

Cancelling fzf leaves the shell alone because the attach command only runs after a successful selection. This lists sessions on the host; run it after connecting, not in a client shell with a different Zellij server.

For my own remote sessions, I sometimes replace the fzf one-liner with the optional $HOME/.local/bin/zpick helper:

mosh --server=/opt/homebrew/bin/mosh-server <mac-user>@<mac-magicdns-name> -- \
  zsh -lc 'export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$HOME/.local/bin:$PATH"; exec "$HOME/.local/bin/zpick" --shell'

It attaches to an existing session, lets me type a name with Ctrl-n to create one, and drops into a login shell when I press Esc or leave the session. That last behavior is useful when I am connecting from a small client and want to inspect the host without starting another multiplexer. It is only a convenience wrapper; if the helper is absent, the explicit commands above remain the workflow.

A small locked-mode configuration

Zellij normally has many keybindings. On a phone or while an editor is running, accidental mode changes are more disruptive than helpful. The following is a complete, deliberately small ~/.config/zellij/config.kdl. It starts locked, permits focus movement without unlocking, and locks again after pane/tab changes. Ctrl-g is the only key that enters normal mode. My full generated config is larger; I publish this compact profile because it preserves the part of my setup that is easy to reproduce, rather than making my personal file a prerequisite.

default_mode "locked"
show_startup_tips false
show_release_notes false

keybinds clear-defaults=true {
    locked {
        bind "Ctrl g" { SwitchToMode "normal"; }
    }

    normal {
        bind "p" { SwitchToMode "pane"; }
        bind "t" { SwitchToMode "tab"; }
        bind "o" { SwitchToMode "session"; }
        bind "r" { SwitchToMode "resize"; }
        bind "Ctrl g" { SwitchToMode "locked"; }
        bind "esc" { SwitchToMode "locked"; }
    }

    pane {
        bind "n" { NewPane; SwitchToMode "locked"; }
        bind "d" { NewPane "down"; SwitchToMode "locked"; }
        bind "r" { NewPane "right"; SwitchToMode "locked"; }
        bind "x" { CloseFocus; SwitchToMode "locked"; }
        bind "esc" { SwitchToMode "locked"; }
    }

    tab {
        bind "n" { NewTab; SwitchToMode "locked"; }
        bind "x" { CloseTab; SwitchToMode "locked"; }
        bind "esc" { SwitchToMode "locked"; }
    }

    session {
        bind "d" { Detach; }
        bind "esc" { SwitchToMode "locked"; }
    }

    resize {
        bind "left" { Resize "Increase left"; SwitchToMode "locked"; }
        bind "down" { Resize "Increase down"; SwitchToMode "locked"; }
        bind "up" { Resize "Increase up"; SwitchToMode "locked"; }
        bind "right" { Resize "Increase right"; SwitchToMode "locked"; }
        bind "esc" { SwitchToMode "locked"; }
    }

    shared_among "normal" "locked" {
        bind "Alt left" { MoveFocusOrTab "left"; }
        bind "Alt down" { MoveFocus "down"; }
        bind "Alt up" { MoveFocus "up"; }
        bind "Alt right" { MoveFocusOrTab "right"; }
    }
}

This is a keymap, not a security boundary. It does not encrypt the terminal, change SSH authentication, or stop a process from accepting input. The Zellij configuration and keybinding documentation explains the modes and actions. Start a new Zellij server/session after changing the file; an existing server may continue using the configuration with which it started.

In the full host config I also leave session serialization disabled. The generated file exposes mouse-mode and pane-frame toggles, but I leave those out of this compact profile so the copy/paste behavior stays explicit. If you want Zellij to save layouts for resurrection, enable serialization deliberately and follow the recovery notes below.

Launch a project from a layout

A layout describes panes and commands to start. It is not a saved copy of process memory. Here is a complete portable layout for a project whose development command is npm run dev; save it as ~/.config/zellij/layouts/myapp.kdl and change the command if the project uses another package manager:

layout {
    pane split_direction="vertical" {
        pane size="60%" {
            command "zsh"
            start_suspended true
        }
        pane size="40%" {
            command "zsh"
            args "-lc" "npm run dev; exec zsh"
            start_suspended true
        }
    }
}

start_suspended true means the command is shown but does not run until you press Enter in that pane. This is intentional: resurrecting a layout must not silently start a server, migration, agent, or other command. Press Enter in the right pane when you are ready. If the command exits, exec zsh leaves an interactive shell so its error remains visible.

For a real project, I keep a separate preset rather than making the portable example depend on my filesystem. My Congrès Médicis preset sets the project working directory and opens OpenCode and development panes suspended, plus a small layout-dump utility pane. That gives me a repeatable shape without starting an agent or dev server merely because I resurrected the workspace; the portable myapp layout above uses the same safety tradeoff with generic commands.

Start a new session from the project directory:

cd "$HOME/src/myapp"
zellij --session myapp \
  --new-session-with-layout "$HOME/.config/zellij/layouts/myapp.kdl"

The --new-session-with-layout option always creates a new session; it does not attach to an existing myapp. For an already-running project, use zellij attach myapp instead. The Zellij layout documentation covers command panes, working directories, and suspended panes.

What survives a disconnect or reboot

There are four different events:

  1. Detach or network loss: the Zellij server and pane processes remain alive on a running Mac. Reconnect and attach to the same session.

  2. Mac sleep: processes normally remain on the host, but network access is unavailable while it sleeps. On wake, SSH/Mosh and Tailscale may need a moment to reconnect; check tailscale status.

  3. Mac reboot or a crashed Zellij server: live process memory is gone. Zellij’s session resurrection stores a serializable layout and pane commands, not the running process state. Attach to an exited session to reconstruct it:

    zellij list-sessions
    zellij attach myapp

    Resurrected command panes normally show a “Press ENTER to run” guard. zellij attach --force-run-commands myapp skips that guard, so use it only when every serialized command is safe to run immediately.

  4. A new session name: no resurrection is involved. It is an empty, independent workspace unless a layout is explicitly supplied.

The layout can restore the shape of the workspace, but it cannot restore an unsaved editor buffer, a process’s in-memory state, or a server’s in-flight request.

Reach one development server privately over HTTPS

First start the local server in a pane and verify that it responds on the host:

curl --fail http://127.0.0.1:3000/

The example below uses the current Tailscale Serve syntax (the CLI changed in version 1.52). It exposes port 3000 to devices on the tailnet, not to the public internet, and Tailscale terminates HTTPS with an automatically provisioned certificate:

tailscale status
tailscale serve status
tailscale serve --bg --https=8443 --set-path=/ 3000
tailscale serve status

Copy the complete HTTPS URL printed by tailscale serve status, including the tailnet suffix and port, into a tailnet-connected browser. It will look like https://mac-mini.example.ts.net:8443/, not https://mac-mini:8443/: Tailscale’s certificate requires the fully qualified name. The short machine name used for SSH is not sufficient for HTTPS. The local target is still 127.0.0.1:3000, so the dev server does not need to listen on a LAN interface.

Serve configuration belongs to the host and may be shared by other projects. The status step is not optional: choose an unused HTTPS port or path after reading the existing routes. Do not run tailscale serve reset as a generic cleanup command; it removes the node’s whole Serve configuration. To remove only this route later, identify both the HTTPS port and root mount with --set-path=/, then check status. A backend target such as 3000 does not scope off to one route; omitting --set-path can remove other handlers on that port:

tailscale serve --https=8443 --set-path=/ off
tailscale serve status

If port 8443 is already used, do not overwrite it. Pick another unused HTTPS port and use that same port in the browser URL and the off command. If you choose a non-root path, repeat that exact --set-path in creation and removal. The Tailscale Serve reference documents --bg, --https, --set-path, status, and off. Serve is different from Tailscale Funnel: this guide intentionally stays tailnet-private and does not publish the development server to the internet.

Troubleshooting

zellij: command not found

Run command -v zellij on the Mac, not on the client. If an interactive SSH shell finds it but mosh host -- zellij ... does not, use the explicit zsh -lc PATH command above or the absolute path reported by command -v. Do not copy a Homebrew path from an Intel Mac to an Apple-silicon Mac.

SSH works but Mosh does not

Mosh needs the SSH bootstrap, a Mosh server on the host, and UDP reachability between the two Tailscale devices. Check mosh --version on both ends, confirm Tailscale is connected, and inspect the host firewall for Mosh’s UDP range. Use SSH while diagnosing; Zellij sessions do not depend on Mosh.

The connection drops

Reconnect with the same session name:

mosh <mac-user>@<mac-magicdns-name> -- zellij attach myapp

If the Mac rebooted, this is not a transport problem: inspect zellij list-sessions and attach the exited session, then deliberately press Enter in each resurrected command pane. If there is no exited session, start the layout again.

Keys appear to do nothing

The supplied config starts in locked mode. Press Ctrl-g once. Alt-arrow focus movement works while locked; pane, tab, resize, and detach actions are available after entering their modes. If Ctrl-g does nothing, confirm that the session was started after the config was installed and that another terminal multiplexer is not intercepting the key.

The layout opened but the server did not start

That is the expected safety behavior of start_suspended true. Focus the server pane and press Enter. Check the pane’s working directory and run the development command manually if npm or the project package is missing.

The browser cannot reach the HTTPS URL

Run these on the host:

curl --fail http://127.0.0.1:3000/
tailscale status
tailscale serve status

The browser device must be logged into the same tailnet. Use the exact MagicDNS name and HTTPS port shown by Serve status; localhost in the browser means the browser device, not the Mac. If the local server binds only to a different port, change the Serve target to that port. If Serve reports an existing route, stop and choose a distinct port or path rather than resetting another project’s configuration.

A route stopped after a reboot

Background Serve routes (--bg) are configured to resume with Tailscale, but the local development process is not resurrected by Serve. Reattach to Zellij, start the project pane, then check tailscale serve status again.

References

§ 05 · Contact

Your turn.

A launch, a rebuild, or a product to keep improving? Tell me the scope, budget and timing. I'll reply within two working days, from Fès.

Book a 30-minute call

ali@mejbar.com. The calendar only offers the times I'm really free.