Temporary LAN Desktop for Human Approval
Use a short-lived browser desktop when an agent is working on a Mac and its owner needs to complete an OS authentication prompt from a phone on the same Wi-Fi. The person enters their existing password on their Mac's desktop; the agent continues with the authorized task after verifying the result.
The tested approach combines a native screen-capture and input helper, a loopback RFB server, a TLS WebSocket proxy, and noVNC. It avoids enabling a persistent remote-management service. The viewer's access token grants control of the entire logged-in desktop, so create it only for a specific, user-approved handoff and shut it down afterward.
Choose the connection method
| Situation | Approach |
|---|---|
| Screen Sharing is already available and authorized | Use the existing server behind an authenticated TLS browser proxy. |
| Enabling Screen Sharing itself needs the password the owner cannot enter locally | Use the temporary helper below, provided its host already has approved capture and input access. |
| Screen Recording or input permission is missing | Have the owner grant it through supported macOS settings. A web viewer cannot solve this bootstrap problem by itself. |
| Phone and Mac are on different networks, guest Wi-Fi, or isolated clients | Use an approved private network solution. This LAN procedure does not configure public tunnels or router forwarding. |
An agent's blocked UI operation remains blocked. Remote access lets the human complete it; the agent must continue using its permitted computer-use tools for its own UI work.
What the session needs
- macOS 14 or later, Xcode Command Line Tools, Git, OpenSSL, and Python 3.13 with
venv. - Existing, authorized ScreenCaptureKit capture and Core Graphics event-posting access for the helper's execution context.
- The Mac's current Wi-Fi address and a phone that can reach it.
- Explicit approval for temporary desktop viewing and control, with an expiry and a cleanup commitment.
The supplied helper is a minimal recovery tool. It captures the primary display at 960 pixels wide and sends raw frames about every 350 ms. It supports basic pointer, scroll, and key events; it is not a production VNC server, a login-window service, or a multi-monitor solution. Confirm that the actual authentication dialog can receive human input before relying on it.
Prepare a private working directory
Keep binaries, tokens, certificates, and logs outside any repository you publish. Choose a dedicated directory for this session:
bash
umask 077
remote_dir=$(mktemp -d "${TMPDIR:-/tmp}/temporary-lan-desktop.XXXXXX")
cd "$remote_dir"
python3.13 -m venv venv
venv/bin/python -m pip install 'websockify==0.13.0'
git clone --depth 1 --branch v1.7.0 https://github.com/novnc/noVNC.git noVNCThese are the versions used in the observed session. Take LANRemote.swift and run.py from this guide and save them in that directory as LANRemote.swift and run.py (remove the download’s .txt suffix). Inspect the source before running it.
bash
swiftc LANRemote.swift -o lan-remote
export LAN_IP=$(ipconfig getifaddr en0)Check that en0 is the active Wi-Fi interface on this Mac. If it is not, set LAN_IP to the observed Wi-Fi address. Bind the browser proxy to that address, and the RFB helper to 127.0.0.1:5901. Do not expose the RFB port on the LAN.
Create TLS for this session
bash
openssl req -x509 -newkey rsa:2048 -nodes -days 1 \
-keyout lan.key -out lan.crt \
-subj '/CN=Temporary LAN desktop' \
-addext "subjectAltName=IP:$LAN_IP,IP:127.0.0.1"
chmod 600 lan.key
openssl x509 -in lan.crt -noout -fingerprint -sha256A self-signed certificate encrypts traffic but does not establish identity through a public certificate authority. Give the owner the expected LAN address and certificate fingerprint. The human must review any browser certificate warning themselves; an agent must not dismiss or bypass it. Use a certificate the client already trusts when one is available.
Start the supervised session
Run the supervisor in a long-lived terminal or an execution session that survives while other work continues:
bash
venv/bin/python run.pyThe supervisor creates a fresh 192-bit random token and a private connection.txt, starts both components, and records manager.pid. It stops them on termination, component failure, or the 30-minute deadline. Read the link in a separate terminal from the same working directory:
bash
cat connection.txtThe URL contains a bearer credential. Share it only with the owner through the current private task. Never put it in a README, issue, screenshot, public chat, or evidence log. Anyone with the link and network access can operate the logged-in desktop; the token is not a Mac-account login requirement. OS authentication prompts still require the owner's password.
The connection path is:
text
Phone browser
→ HTTPS and authenticated WebSocket on the Mac's LAN address:6080
→ websockify TokenFile authorization
→ loopback-only RFB at 127.0.0.1:5901
→ native capture and input helper in the current user sessionThe RFB helper advertises no RFB authentication. Its security boundary is the token-gated TLS proxy plus loopback binding. Keep both controls in place. Static viewer files may load without a token; that does not grant a desktop connection.
Verify before the human enters a password
- Check listeners with
lsof -nP -iTCP:5901 -iTCP:6080 -sTCP:LISTEN. Expect RFB on loopback and the browser proxy only on the selected LAN address. - Verify HTTPS using the session certificate as a trust anchor, for example
curl --cacert lan.crt "https://$LAN_IP:6080/vnc.html" -o /dev/null. Do not disable certificate validation in the verification script. - Open the token link and confirm that noVNC connects and shows a nonblank current desktop. A successful HTTP response alone proves neither capture nor input.
- Try a WebSocket connection without a token. It must be rejected before the RFB session is established. Merely loading
vnc.htmlis not this test. - Ask the owner to perform one harmless pointer action, then enter their password directly into the intended macOS prompt. Do not echo, log, inspect, or store keystrokes.
- Verify the intended result through the application or CLI: an installation receipt, the correct Accessibility grant, or successful export of only the selected signing identities.
Use agent-side browser inspection only if the tool permits it. In the observed session, a separate loopback browser proxy was used for a read-only viewer test; it was shut down with the main session. It is optional and intentionally omitted from the reusable supervisor.
Stop and prove access is gone
After the task succeeds, check that the recorded PID still belongs to this session's supervisor before sending a signal:
bash
manager_pid=$(cat manager.pid)
ps -p "$manager_pid" -o pid=,command=
kill -TERM "$manager_pid"
lsof -nP -iTCP:5901 -iTCP:6080 -sTCP:LISTENThe final listener check should return no matching sockets. Confirm the helper and proxy processes exited and the token and connection files were removed. Only then remove this session's generated private key, certificate, and private logs. Do not kill unrelated processes merely because they use a similar name or port.
If native Screen Sharing was enabled for the task, restore its previous setting. In the observed session, its authentication request was canceled and the service remained off; there was no service setting to restore. No SSH service, login item, launch daemon, or router rule was added.
The expiry is a backstop. Close the session explicitly when the work is done, and report both the application outcome and the remote-access shutdown.
Troubleshooting
| Symptom | Next check |
|---|---|
| Phone cannot connect | Confirm both devices are on the same network, the observed address is current, and client isolation or firewall rules are not blocking it. |
| Viewer loads but connection fails | Check the token, its encoded WebSocket path, proxy listener, and session expiry. Generate a new link for a restarted session. |
| Black or stale desktop | Check capture authorization and the native helper's log. Stop if capture fails rather than widening permissions silently. |
| Pointer moves but dialog rejects input | Confirm approved event-posting access and test the actual dialog with the human. Do not use the helper to bypass an agent UI restriction. |
| Password prompt requires repeated approval | Distinct operations, such as installation, settings changes, and private-key export, may need separate human authentication. Keep the viewer alive only for the remaining approved steps. |
| A component exits | The supervisor shuts down the session. Diagnose first, then restart with a fresh token and deadline. |
Observed outcome
During ClickMore distribution setup on 10 October 2026, the owner was on a phone on the same Wi-Fi. Enabling built-in Screen Sharing required local authentication, so a temporary user-session server was used instead. The phone viewer let the owner authenticate Installer and Privacy & Security. The notarized PKG installed successfully, the installed app's cross-process click test passed, and the temporary server's listeners were verified closed afterward.
The viewer was later restarted for CI signing-key export, with a fresh token. Each restart is a new short-lived connection; do not preserve old links as instructions or treat a successful earlier handoff as proof that a later task succeeded.