Guide · SSH

Use your secrets on another Mac over SSH

You work on a second Mac through SSH and its commands need keys that live on your laptop. Copying a .env file across leaves a plain-text copy behind.

In shortConnect with ssh -R to forward Latchkey's socket, set LATCHKEY_SOCKET on the other Mac, and run latchkey run there. The request reaches the app on your own Mac, which asks you to approve each read of an item that needs approval.

Why files are the wrong answer

A remote shell has no Touch ID and no keychain of yours. The usual fixes are to copy the env file over, or to paste values into the session. Both leave the values in a file or in shell history on a machine you may not control as tightly as your laptop.

Latchkey's command-line tool never touches the keychain. It asks the app over a Unix socket. If you forward that socket over SSH, the tool on the far Mac asks the app on your Mac, and the approval appears where you are sitting.

Set it up

Your Mac needs the Latchkey app running; the other Mac needs the latchkey tool, which is macOS only. Forwarding needs the direct-download app on your Mac: the Mac App Store version doesn't support it yet. If the other Mac has the App Store version installed, set LATCHKEY_BROKER=direct there too. $USER expands to your login name on each Mac: use the same name on both, or put a fixed name in both commands.

  1. Forward the socket when you connect

    Run this on your own Mac, with the Latchkey app running. devmac is an example host name.

    Your Mac
    ssh -o StreamLocalBindUnlink=yes \
      -R /tmp/latchkey-$USER.sock:"$HOME/Library/Application Support/Latchkey/broker.sock" \
      devmac
  2. Point the tool at the forwarded socket

    In that SSH session, on the other Mac, set LATCHKEY_SOCKET to the path you forwarded to.

    The other Mac
    export LATCHKEY_SOCKET=/tmp/latchkey-$USER.sock
  3. Run your command

    Use latchkey run as you would at home. Here shop/development is an example environment.

    The other Mac
    latchkey run --env shop/development -- npm test
  4. Approve on your Mac

    The approval panel opens on your own Mac. It says the request came over SSH and shows what the tool on the other computer says it is running, marked as unchecked. Approve with Touch ID, or deny. A request nobody answers is denied after two minutes.

What is different from working locally

The Agents and MCP reference has the same setup in short form, and Security explains how Latchkey identifies callers.

What this doesn't do

Related