# Phone & remote access

Carry on from your phone: direct on the LAN, remote when away.

Web page: https://gerdr.dev/docs/remote

From outside, you go through a cloud relay, encrypted all the way to your own computer; the relay only ever passes ciphertext along. A new device gets in the first time with a **pairing code** (only someone at the computer can make one), then adds a **passkey**, so later devices don't need a trip back to the computer.

- **Pairing:** Settings → Remote access → make a pairing code, scan it with your phone and you're in. A code works once, within 5 minutes.
- **Passkey:** in Gerdr on your phone, Settings → Remote access → add a passkey.
- **Sign out a device:** click Sign out in Settings, or run `gerdr remote revoke`.
- **Android app:** the same interface as the web, faster at home over a direct LAN connection, with background notifications.

The first time, connect this computer to a relay; the steps are in the README's [remote access](https://github.com/gerdr-dev/gerdr/blob/main/README.md#remote-access) section. Rather not use a relay? See direct access below.

## Direct access: Tailscale or frp instead of the relay

Gerdr only serves one port (7878 by default) with your domain's certificate, under the same pairing-code and passkey rules as the relay; how the phone reaches this computer is up to your own network. You still need a certificate (passkeys only work over HTTPS), but it's issued over DNS, so your computer doesn't have to be reachable from the internet.

### With Tailscale (nothing exposed to the internet)

1. **Install Tailscale on both**: Install Tailscale on the computer and the phone, and sign both into the same account.

2. **Turn on direct access in Gerdr**: Settings → Remote access → Direct access: enter your domain (e.g. `gerdr.example.com`), leave Port in the address empty, and connect. Then under Certificate below, pick your DNS provider and enter its API credentials; the certificate is issued and renewed by itself.

   Rather not click through the UI? Run one command in the computer's terminal instead; it does exactly the same (writes the config, and the running Gerdr picks it up at once; an agent setting this up for you uses it too):

```
gerdr remote direct gerdr.example.com \
  --dns cloudflare \
  --env CLOUDFLARE_DNS_API_TOKEN=your-token
```

3. **Add a DNS record**: An A record: `gerdr.example.com → 100.x.y.z`, this computer's Tailscale address (shown on the settings page). Only devices in your Tailscale network can reach it.

4. **Open it on the phone**: With Tailscale on, open `https://gerdr.example.com:7878` on the phone and scan a pairing code to get in. Enter the same address in the Android app.

> Why it connects with no other setup: the domain itself points at the Tailscale address, and Tailscale on the phone is a system VPN, so connections from both the browser and the app go through it to your computer. Conversely, with Tailscale off on the phone the address won't open (at home the Android app can still use the LAN). The address carries `:7878` because macOS won't let an ordinary program take port 443 on a specific address.

### With frp or a router's port forward

In Direct access, set Port in the address to `443` (with the command, add `--url-port 443` to the one above), point the A record at the frps machine (or your public IP), and the address is `https://gerdr.example.com`. frps needs `vhostHTTPSPort = 443`; add this to frpc:

```
[[proxies]]
name = "gerdr"
# pass TLS through untouched; never the https2http plugin
type = "https"
customDomains = ["gerdr.example.com"]
localIP = "127.0.0.1"
localPort = 7878
# optional: let Gerdr see the real client IP
transport.proxyProtocolVersion = "v2"
```

- **Firewall:** the first time, macOS may ask whether Gerdr may accept incoming connections. Click Allow, or the phone can't get in, and nothing tells you why.
- **Passkeys in the Android app:** with a port in the address, the app can't use a passkey directly (Android only checks the app on 443), so sign-in is approved in the browser instead; or enter the code on the computer under Settings → Remote access → Approve app sign-in.
