This is the complete LinkJar PDS documentation, as Markdown.
# Your data. Your server. The open network.
> Host your accounts, records, and media with an open-source AT Protocol Personal Data Server written in Rust. Install, migrate, and operate LinkJar PDS.
[Source](https://pds.linkjar.io/)
A PDS you can make your own
A small starting point.\
Room to grow.
-------------
### Start with one host.
Run a native Rust binary, use NixOS, or choose Docker Compose. Keep repositories in SQLite and media on disk.
[Builds and installation ↗](https://pds.linkjar.io/start/builds/)
### Keep your options open.
Use S3-compatible blob storage or Postgres for shared state. Separate routing with an entryway and a member server.
[Explore deployment options ↗](https://pds.linkjar.io/scale/entryway/)
### Know what you operate.
Inspect the source, verify repositories, and export account data. Follow guides for backups, monitoring, and updates.
[Meet the operator tools ↗](https://pds.linkjar.io/operate/cli/)
From first install to daily operations
Your next step\
is in the guide.
----------------
A practical path from a Linux host to your first account. Then the details that keep it running.
[Explore the documentation →](https://pds.linkjar.io/start/overview/)
1. ### [Prepare a host and domain](https://pds.linkjar.io/start/requirements/)
Choose your runtime, then check storage and DNS.
2. ### [Configure and start the server](https://pds.linkjar.io/start/builds/)
Pin your build, generate secrets, and check your configuration.
3. ### [Verify it. Create an account.](https://pds.linkjar.io/start/verify/)
Check HTTPS and health, then make your first invite.
# Host your own PDS
> Install, migrate, and operate your AT Protocol server.
[Source](https://pds.linkjar.io/start/overview/)
LinkJar PDS is an AT Protocol Personal Data Server written in Rust. Host your accounts, records, and media, and connect them to the wider network.
This guide takes you from a Linux host to your first account, then covers the work of keeping the server running.
## Choose your starting point
[Set up a new server](https://pds.linkjar.io/start/requirements/) Prepare a host and domain, then choose Nix, a native binary, or Docker Compose.
[Move from the reference PDS](https://pds.linkjar.io/operate/migrate-from-reference/) Check your existing data, plan the switch, and review rollback limits.
## Choose how to run it
[Native Linux](https://pds.linkjar.io/start/native/#linux-binary-with-systemd) A portable AMD64 or ARM64 binary, managed by systemd.
[NixOS](https://pds.linkjar.io/start/native/#nixos-service) A pinned package, a service module, and declarative configuration.
[Docker Compose](https://pds.linkjar.io/start/install/) A container deployment with a pinned image and persistent volumes.
[Understand the pieces](https://pds.linkjar.io/reference/binaries/) The PDS, console, and MCP binaries: what each does and which ports it uses.
## Get a server running
Choose [Nix, a native binary](https://pds.linkjar.io/start/native/), or [Docker Compose](https://pds.linkjar.io/start/install/). All three run the same server and use the same data layout. The examples use SQLite and local blobs, with Caddy handling public HTTPS.
1. **[Prepare the host](https://pds.linkjar.io/start/requirements/)**
Check your chosen runtime, storage, network access, and domain.
2. **[Set up DNS](https://pds.linkjar.io/start/dns/)**
Point the server name and account handles at your host.
3. **Choose a build and install**
Read [builds and downloads](https://pds.linkjar.io/start/builds/), then install with [Nix or a binary](https://pds.linkjar.io/start/native/) or [Docker Compose](https://pds.linkjar.io/start/install/). Pin the build, generate secrets, and check configuration before startup.
4. **[Verify the setup](https://pds.linkjar.io/start/verify/)**
Check HTTPS, server metadata, and health from outside the host.
5. **[Create your first account](https://pds.linkjar.io/start/first-account/)**
Make an invite, create an account, and sign in with a client.
## Connect your tools
[Connect an AI client](https://pds.linkjar.io/connect/mcp/) Give an MCP client access to your account through sign-in and consent.
[Open the operations console](https://pds.linkjar.io/connect/console/) Inspect accounts, sessions, and audit events through a private connection.
For help with installation, [bring these guides to your AI assistant](https://pds.linkjar.io/connect/ai-guidance/). The manual steps remain available for every deployment method.
## Keep it running
[Back up and restore](https://pds.linkjar.io/operate/backup/) Keep account data, blobs, and the secrets needed to recover them.
[Update the server](https://pds.linkjar.io/operate/update/) Update a pinned binary, NixOS package, or image and review rollback limits.
[Monitor the service](https://pds.linkjar.io/operate/monitoring/) Read logs, check health, and collect operational metrics.
[Find a setting](https://pds.linkjar.io/configure/environment/) Environment variables, defaults, and request resource limits.
> **Before hosting other people's data**
>
> Set up [email for account recovery](https://pds.linkjar.io/configure/email/), keep a tested [backup](https://pds.linkjar.io/operate/backup/), and review the [authentication limits when rolling back](https://pds.linkjar.io/operate/update/#roll-back). A database that an older server can read does not guarantee the same credential-revocation protection.
## Understand the system
The [architecture guide](https://pds.linkjar.io/reference/architecture/) explains the server’s parts and data files. For larger deployments, start with [Postgres](https://pds.linkjar.io/scale/postgres/) or the [entryway and member model](https://pds.linkjar.io/scale/entryway/). If a check fails, use the [troubleshooting guide](https://pds.linkjar.io/reference/troubleshooting/).
These pages describe LinkJar PDS. The upstream [AT Protocol documentation](https://atproto.com/) explains the protocol, and its [self-hosting guide](https://atproto.com/guides/self-hosting) links to the reference server. LinkJar’s implementation and deployment instructions are maintained in the [source repository](https://github.com/linkjar/pds).
# What you need
> Prepare a Linux host, choose Docker or a native installation, and configure the domain and network access for LinkJar PDS.
[Source](https://pds.linkjar.io/start/requirements/)
A PDS holds the accounts of a few people and talks to the rest of the network for them. One small host is enough.
## A host
| | |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| Operating system | Linux, on `amd64` or `arm64` |
| Software | Docker Engine with Compose, or [Nix / a native executable](https://pds.linkjar.io/start/native/) |
| Memory | 1 GiB is plenty. The server starts in a few MiB; Caddy takes a few tens |
| Disk | 20 GB to start. Records live in SQLite files, images and videos as files beside them |
| Network | A public IP address, with ports 80 and 443 open to the internet |
If you choose the Compose deployment, check Docker on the host:
```bash
docker compose version
```
It prints `Docker Compose version v2…`. The older `docker-compose` with a hyphen, version 1, does not read the Compose file of this guide.
## A domain name
The server needs a name of its own, such as `pds.example.com`, at a DNS provider where you can add a wildcard record. Each account gets a handle under that name, `alice.pds.example.com`, and each handle is a name the server answers for. [Point DNS at the host](https://pds.linkjar.io/start/dns/) has the records.
Keep the PDS on a domain of its own, not on a subdomain of a site that serves a web app. The server’s authorization pages and the blobs it serves should not share a parent domain with an app’s cookies.
## HTTPS and CA certificates
The Compose deployment includes Caddy. A native installation needs its own TLS proxy; the [native guide](https://pds.linkjar.io/start/native/#public-https) includes a Caddy example. Caddy uses an operator email for certificate notices. Native hosts also need a CA certificate bundle for the PDS’s outbound HTTPS requests.
## Optional: an SMTP account
The server sends mail to confirm an address and to reset a password. Without SMTP it sends none, which is fine for a server of one. [Email](https://pds.linkjar.io/configure/email/) has the setup.
## Placeholders in this guide
| Placeholder | Replace with |
| ---------------------- | ---------------------------------- |
| `pds.example.com` | the name of your server |
| `203.0.113.10` | the public IP address of your host |
| `operator@example.com` | your email address |
| `alice` | the first account’s handle |
Run commands on the host unless a page says otherwise. Docker commands run from the Compose directory. Native service commands use the service user and runtime configuration, as explained in [the CLI guide](https://pds.linkjar.io/operate/cli/).
# Builds and downloads
> Choose a native package, download a checked Linux binary, or build LinkJar PDS with Nix or Cargo.
[Source](https://pds.linkjar.io/start/builds/)
`linkjar-pds` is the Rust server executable. Choose a build for your host, then follow [native installation](https://pds.linkjar.io/start/native/) for configuration and startup.
| Build | Platforms | Needs on the destination host |
| -------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------- |
| Nix package | `x86_64-linux`, `aarch64-linux`, `aarch64-darwin` | Nix and the package’s store closure |
| Portable static executable | `x86_64-linux`, `aarch64-linux` | Linux and a CA certificate bundle; no Nix or Docker |
| Cargo release build | The build host’s supported Rust target | Its runtime libraries and CA certificates |
| [Container image](https://pds.linkjar.io/start/install/) | Linux AMD64 and ARM64 | Docker Engine and Compose |
The Linux packages are built on their own architectures. Apple Silicon supports the normal Nix package for local use. There is no Intel macOS package or portable macOS archive. The packages contain the PDS server; console and MCP sidecars are separate builds. See [binaries and ports](https://pds.linkjar.io/reference/binaries/) for their build commands, runtime files, and network connections.
## Download a portable Linux build
Open the [Native packages workflow](https://github.com/linkjar/pds/actions/workflows/nix.yml). Choose a successful run and check its source commit before downloading. Use a reviewed `main` build for an installation. Pull request artifacts are review builds and can contain unmerged changes.
The artifacts are `linkjar-pds-x86_64-linux` and `linkjar-pds-aarch64-linux`. Each contains a `.tar.gz` archive and its `.tar.gz.sha256` checksum file. GitHub keeps them for 14 days. They require GitHub access to download and are not permanent GitHub Release assets. Build from a pinned revision if an artifact has expired.
With the GitHub CLI, list successful main builds:
```bash
gh run list --repo linkjar/pds --workflow nix.yml --branch main --status success
```
Set the run ID you reviewed, then inspect its commit and result:
```bash
PDS_RUN_ID=REPLACE_WITH_REVIEWED_RUN_ID
gh run view "$PDS_RUN_ID" --repo linkjar/pds --json headSha,event,status,conclusion,url
```
Select the host architecture:
```bash
case "$(uname -m)" in
x86_64) PDS_SYSTEM=x86_64-linux ;;
aarch64|arm64) PDS_SYSTEM=aarch64-linux ;;
*) echo 'No portable build for this architecture' >&2; exit 1 ;;
esac
```
On Linux, download into a new, empty directory:
```bash
gh run download "$PDS_RUN_ID" --repo linkjar/pds \
--name "linkjar-pds-$PDS_SYSTEM" --dir native-download
```
Verify the archive before extracting it:
```bash
(cd native-download && sha256sum --check "linkjar-pds-$PDS_SYSTEM.tar.gz.sha256") &&
mkdir native-unpack &&
tar -xzf "native-download/linkjar-pds-$PDS_SYSTEM.tar.gz" -C native-unpack &&
./native-unpack/linkjar-pds version
```
A checksum detects damaged or changed downloads. Also check the run’s repository and source commit; the checksum alone does not establish who built it. The CLI version is the Cargo package version and can be shared by several commits. Keep the full commit and archive checksum in your deployment record.
Install the reviewed executable in a directory named after its commit:
```bash
PDS_REV=$(gh run view "$PDS_RUN_ID" --repo linkjar/pds --json headSha --jq '.headSha') &&
sudo install -d -m 0755 "/opt/linkjar-pds/$PDS_REV" &&
sudo install -m 0755 native-unpack/linkjar-pds "/opt/linkjar-pds/$PDS_REV/linkjar-pds" &&
sudo install -m 0644 native-unpack/LICENSE "/opt/linkjar-pds/$PDS_REV/LICENSE" &&
sudo ln -sfn "/opt/linkjar-pds/$PDS_REV/linkjar-pds" /usr/local/bin/linkjar-pds
```
This symlink is for a new installation. For an existing server, follow [the update procedure](https://pds.linkjar.io/operate/update/#native-binary) before changing it. Keep CA certificates installed for outbound HTTPS. Set `SSL_CERT_FILE` in the service environment if the bundle is in a nonstandard location.
## Build with Nix
Use Nix with the `nix-command` and `flakes` experimental features enabled. Check out the reviewed source commit and run these commands from the repository root. Keep `flake.lock` and `Cargo.lock` unchanged for that build.
```bash
nix build .#linkjar-pds
result/bin/linkjar-pds version
nix run . -- version
```
The normal package uses libraries in the Nix store. Keep the `result` symlink as a garbage-collection root, or install the package through your host’s Nix configuration. Copying just this executable to another host is insufficient. Use the NixOS module for a persistent NixOS installation.
On a Linux builder, create a portable static musl executable instead:
```bash
nix build .#linkjar-pds-static --out-link result-static
result-static/bin/linkjar-pds version
```
Copy `result-static/bin/linkjar-pds` to a Linux host with the same CPU architecture. The static executable has no dynamic loader or shared-library dependency. Its throughput has not been benchmarked against the normal package; compare your workload before changing a production build.
`flake.lock` pins Nixpkgs and rust-overlay. The overlay resolves the toolchain in `rust-toolchain.toml` against those locked inputs. `Cargo.lock` pins the Rust dependencies. A normal build does not update either lockfile.
## Build with Cargo
Install the toolchain selected by `rust-toolchain.toml`, a C compiler, CMake, and pkg-config. Build only the server:
```bash
cargo build --release --locked --package linkjar-pds --bin linkjar-pds
target/release/linkjar-pds version
```
The output is `target/release/linkjar-pds`. It targets the build host and can depend on its shared libraries. Node, pnpm, the console assets, and the simulation are not required to compile this server target.
For a development shell with the workspace tools:
```bash
nix develop
```
## What CI checks
The **Native packages** workflow evaluates all supported platforms, then builds the normal and static packages on both Linux architectures. It checks the copied static executable for dynamic dependencies and tests configuration, startup, HTTP health, graceful shutdown, and database verification on temporary data. An x86-64 NixOS VM test checks the service user, state permissions, persistence, restart, and firewall isolation.
The separate **Rust** workflow runs the workspace tests and Rust checks. The **Site** workflow validates documentation and saves the static `pds-docs` artifact. These workflows do not deploy the server or documentation. The docs are hosted on Cloudflare Workers at [pds.linkjar.io](https://pds.linkjar.io/); GitHub Pages is not used.
Next: [configure and run the native server](https://pds.linkjar.io/start/native/).
# Binaries and ports
> The PDS, operations console, and MCP server, their build targets, and the network connections between them.
[Source](https://pds.linkjar.io/reference/binaries/)
Start with `linkjar-pds`. Add the console for operators or the MCP server for AI clients when you need them. Each is a separate Rust executable.
## What runs where
| Executable | Purpose | Distribution |
| --------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `linkjar-pds` | Hosts accounts, repositories, blobs, OAuth, and the optional private operations API | Nix package, portable Linux archive, Cargo, or Docker |
| `linkjar-pds-console` | Gives operators a browser interface to the private operations API | Cargo with its asset bundle, or `Dockerfile.console` |
| `linkjar-pds-mcp` | Connects an AI client to an account through MCP and OAuth | Cargo, or `Dockerfile.mcp` |
The Nix package and portable archives currently include **only `linkjar-pds`**. There are no published native sidecar archives or sidecar NixOS modules in this repository. The `pds-sidecar` crate is a shared library, not another executable.
The console and MCP server use authenticated APIs. They do not open the PDS database or need its admin password or PLC rotation key. The MCP server has its own OAuth client key.
## Network map
| Service | Native address or port | Who connects |
| ------------------ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| TLS proxy | Public `443`; usually `80` for HTTPS redirects and certificate setup | Apps, browsers, relays, and remote AI clients |
| PDS HTTP | `2583`, on all interfaces; `PDS_PORT` changes it | The proxy and trusted sidecars; block public access with the host firewall |
| PDS operations API | Disabled unless `PDS_OPS_ADDRESS` is set; use `127.0.0.1:2584` on one host | The console and authorized operator tools |
| Operations console | `127.0.0.1:2585`; set with `CONSOLE_ADDRESS` | Your browser through an SSH tunnel |
| MCP HTTP | `127.0.0.1:2586`; set with `MCP_ADDRESS` | A TLS proxy for the MCP hostname |
Port `2584` is a convention in the examples, not an automatically enabled listener. Keep it private. The console’s browser URL must be an HTTP loopback address; a public console hostname is not supported.
The PDS image sets its internal HTTP port to `3000`. Compose sidecars use `http://pds:3000`; sidecars beside a native installation use `http://127.0.0.1:2583`. Inside a container, `127.0.0.1` is that container, not the host or a sibling service. Use the [Compose examples](https://pds.linkjar.io/scale/sidecars/) for that topology.
## Platforms and runtime files
| Build | Supported package targets | Files to retain |
| ------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| Normal PDS Nix package | Linux AMD64, Linux ARM64, Apple Silicon macOS | The Nix store closure |
| Portable PDS archive | Linux AMD64 and Linux ARM64 | The executable, license, deployment commit, and checksum |
| Sidecars built with Cargo | Build for the intended host; no portable sidecar release matrix yet | Executable and required runtime libraries; the console also needs its `assets/` directory |
Native services need CA certificates for outbound HTTPS. The MCP and console keep sessions in memory, so restarting either requires its users to sign in again. The PDS data directory must persist independently of executable updates.
## Build the sidecars
Use a reviewed checkout and the toolchain in `rust-toolchain.toml`. The [build prerequisites](https://pds.linkjar.io/start/builds/#build-with-cargo) apply here too.
**Build the MCP server**
```bash
cargo build --release --locked --package pds-mcp --bin linkjar-pds-mcp
```
**Build and bundle the operations console**
```bash
cargo build --release --locked --package pds-console --bin linkjar-pds-console &&
target/release/linkjar-pds-console bundle-assets target/release/assets
```
Bundle the console assets **on the build machine**, before copying the executable elsewhere. Copy `target/release/assets/` alongside the executable as `assets/`. Without that bundle, the console attempts to build its assets at runtime using files from the source tree.
The console build downloads a pinned, checksum-verified Tailwind CLI. To use an existing compatible executable, set `TAILWIND_CLI` before building.
## Choose the next guide
* [Install the native PDS](https://pds.linkjar.io/start/native/) or [use Docker Compose](https://pds.linkjar.io/start/install/).
* [Connect an AI client with MCP](https://pds.linkjar.io/connect/mcp/).
* [Set up the operations console](https://pds.linkjar.io/connect/console/).
* [Use the PDS operator commands](https://pds.linkjar.io/operate/cli/).
# Point DNS at the host
> The two records a PDS needs, the ports to open, and how to check both before you install.
[Source](https://pds.linkjar.io/start/dns/)
Add two records at your DNS provider. Both point at the host.
| Name | Type | Value |
| ------------------- | ---- | -------------- |
| `pds.example.com` | `A` | `203.0.113.10` |
| `*.pds.example.com` | `A` | `203.0.113.10` |
Add `AAAA` records with the same names when the host has a public IPv6 address.
The wildcard matters. An account’s handle, `alice.pds.example.com`, is a host name of its own: apps resolve it to find the account’s DID, and Caddy fetches a certificate for it the first time a client asks. Without the wildcard, handles do not resolve.
> **DNS only, no proxy**
>
> If your DNS provider can proxy traffic through its own edge, leave the proxy off for both records. Caddy needs to answer the certificate challenge itself, and the firehose is a WebSocket that stays open for hours.
## Check the records
Wait until both answers are right. A DNS change takes a few minutes to spread.
```bash
dig +short pds.example.com
```
```bash
dig +short anything.pds.example.com
```
Each prints `203.0.113.10`.
## Open the ports
Open ports 80 and 443 in the host’s firewall and in your provider’s firewall, if it has one. Port 80 serves the certificate challenge and the redirect to HTTPS; 443 serves everything else. The Compose server listens on port `3000` inside its network. Native examples use port `2583`, blocked from public access by the host firewall. Send public traffic through the TLS proxy; keep metrics and operations listeners private.
Next: [choose a build](https://pds.linkjar.io/start/builds/), then install with [Nix or a binary](https://pds.linkjar.io/start/native/) or [Docker Compose](https://pds.linkjar.io/start/install/).
# Install with Nix or a binary
> Configure a native LinkJar PDS, run it with systemd or NixOS, and put HTTPS in front of it without Docker.
[Source](https://pds.linkjar.io/start/native/)
The server runs as one Rust executable. First [download or build it](https://pds.linkjar.io/start/builds/). For Linux without Nix, use the portable static executable. On NixOS, use the module below. A foreground example is included for local checks.
You need a domain, a writable data directory, a blob store, CA certificates, and a TLS proxy for public HTTPS. The HTTP listener binds all interfaces. Keep port `2583` behind the host’s firewall and allow public traffic through your TLS proxy. Never enable `PDS_DEV_MODE` on a public host.
## Configure the server
For a new installation, generate a JWT secret and admin password separately:
```bash
openssl rand --hex 32
openssl rand --hex 32
```
Generate a secp256k1 PLC rotation key on Linux:
```bash
openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32
```
Keep these values in a secret manager or a restricted file. Reuse the original secrets when moving an existing server. The rotation key controls the accounts’ DIDs; replacing it is not an installation reset.
Create `/etc/linkjar-pds/pds.env`, owned by root with mode `0600`, under a root-owned directory. Create the directory before editing the file:
```bash
sudo install -d -m 0700 -o root -g root /etc/linkjar-pds
sudoedit /etc/linkjar-pds/pds.env
sudo chmod 0600 /etc/linkjar-pds/pds.env
```
Put one literal `NAME=value` assignment on each line. Replace the three secret placeholders:
**/etc/linkjar-pds/pds.env**
```dotenv
PDS_HOSTNAME=pds.example.com
PDS_JWT_SECRET=REPLACE_WITH_JWT_SECRET
PDS_ADMIN_PASSWORD=REPLACE_WITH_ADMIN_PASSWORD
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=REPLACE_WITH_ROTATION_KEY
PDS_BLOBSTORE_DISK_LOCATION=/var/lib/linkjar-pds/blocks
PDS_INVITE_REQUIRED=true
PDS_BSKY_APP_VIEW_URL=https://api.bsky.app
PDS_BSKY_APP_VIEW_DID=did:web:api.bsky.app
PDS_REPORT_SERVICE_URL=https://mod.bsky.app
PDS_REPORT_SERVICE_DID=did:plc:ar7c4by46qjdydhdevvrndac
PDS_CRAWLERS=https://bsky.network
```
Systemd reads this file; the binary does not load `.env` files itself. Keep all settings needed by operator commands in this runtime file. The examples below set `PDS_DATA_DIRECTORY` and `PDS_PORT` in the service definition. Leave them out of the file so they cannot override those settings.
For [S3 storage](https://pds.linkjar.io/configure/blob-storage/), remove `PDS_BLOBSTORE_DISK_LOCATION` and add the S3 settings and credentials. Set up [email](https://pds.linkjar.io/configure/email/) before inviting other people. [Environment variables](https://pds.linkjar.io/configure/environment/) lists the remaining options.
## NixOS service
Add a pinned input to your host’s flake. Replace `` with the full commit you intend to run:
```nix
inputs.linkjar-pds.url = "github:linkjar/pds/";
```
Add `inputs.linkjar-pds.nixosModules.default` to your host’s `modules` list. In a host module, enable the service and put the same package on the operator’s command path:
```nix
{ inputs, pkgs, ... }:
{
services.linkjar-pds = {
enable = true;
environmentFile = "/etc/linkjar-pds/pds.env";
};
environment.systemPackages = [
inputs.linkjar-pds.packages.${pkgs.stdenv.hostPlatform.system}.linkjar-pds
];
}
```
This example assumes your flake passes `inputs` through `specialArgs` to the host modules. You can instead reference the input in the outer flake expression.
Provision the runtime file before activating the service. Your existing secret manager can supply it at another runtime path, such as `/run/secrets/linkjar-pds.env`. Use a quoted string for `environmentFile`; never put secrets in a Nix expression, `builtins.toFile`, or a Nix path copied into the store.
The module creates the `linkjar-pds` user and group and mode `0700` state at `/var/lib/linkjar-pds`. It checks configuration before startup, restarts after failure, and restricts filesystem access. It supplies CA certificates and keeps the HTTP port closed in the firewall by default. Set `services.linkjar-pds.port` if you need a port other than `2583`. Configure your TLS proxy separately.
Activate the reviewed host configuration with your usual `nixos-rebuild` procedure. Then check the service:
```bash
sudo systemctl status linkjar-pds
sudo journalctl -u linkjar-pds -n 50 --no-pager
curl --fail http://127.0.0.1:2583/xrpc/_health
```
The service protects `/home` and `/root`. Keep additional key files in an accessible runtime secret directory. Use `services.linkjar-pds.environment` only for public settings; [operator commands](https://pds.linkjar.io/operate/cli/#native-services) need those settings too.
## Linux binary with systemd
This example uses the executable installed at `/usr/local/bin/linkjar-pds` by the [download guide](https://pds.linkjar.io/start/builds/#download-a-portable-linux-build). Keep the host’s CA certificate package installed.
Create a dedicated account and data directory. On Debian or Ubuntu:
```bash
sudo useradd --system --user-group --home-dir /var/lib/linkjar-pds --shell /usr/sbin/nologin linkjar-pds
sudo install -d -m 0700 -o linkjar-pds -g linkjar-pds /var/lib/linkjar-pds
```
Create the account only once. If you use another distribution, use its system account command. Save this unit as `/etc/systemd/system/linkjar-pds.service`:
**/etc/systemd/system/linkjar-pds.service**
```ini
[Unit]
Description=LinkJar AT Protocol Personal Data Server
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=linkjar-pds
Group=linkjar-pds
WorkingDirectory=/var/lib/linkjar-pds
EnvironmentFile=/etc/linkjar-pds/pds.env
Environment=PDS_DATA_DIRECTORY=/var/lib/linkjar-pds
Environment=PDS_PORT=2583
ExecStartPre=/usr/local/bin/linkjar-pds check-config
ExecStart=/usr/local/bin/linkjar-pds serve
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StateDirectory=linkjar-pds
StateDirectoryMode=0700
UMask=0077
NoNewPrivileges=true
PrivateTmp=true
PrivateDevices=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=
[Install]
WantedBy=multi-user.target
```
After saving the runtime environment file and firewall rules, start it:
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now linkjar-pds
sudo systemctl status linkjar-pds
sudo journalctl -u linkjar-pds -n 50 --no-pager
curl --fail http://127.0.0.1:2583/xrpc/_health
```
## Public HTTPS
Point the TLS proxy at `127.0.0.1:2583`. It must handle the server hostname, account handle names, and long-lived WebSocket connections for the firehose. For a native Caddy installation, adapt the repository’s Caddyfile:
**Caddyfile**
```caddyfile
{
email operator@example.com
on_demand_tls {
ask http://127.0.0.1:2583/tls-check
}
}
pds.example.com, *.pds.example.com {
tls {
on_demand
}
reverse_proxy 127.0.0.1:2583
}
```
Run Caddy as its own service with persistent certificate storage. The DNS and ports in [the DNS guide](https://pds.linkjar.io/start/dns/) apply to this setup too. The `/tls-check` guard limits certificate requests to the server and active account handles. For a different proxy, configure equivalent hostname, TLS, and WebSocket support.
## Foreground checks
On a private development host, run the binary as your own user with disposable state. Set the required settings in that shell first:
```bash
export PDS_HOSTNAME=pds.example.com
export PDS_DATA_DIRECTORY="$PWD/native-data"
export PDS_BLOBSTORE_DISK_LOCATION="$PWD/native-data/blocks"
export PDS_JWT_SECRET=REPLACE_WITH_JWT_SECRET
export PDS_ADMIN_PASSWORD=REPLACE_WITH_ADMIN_PASSWORD
linkjar-pds check-config
linkjar-pds serve
```
Use the executable path from your build if it is not installed on `PATH`. Stop it with Ctrl-C. This example does not configure public TLS or a rotation key for creating accounts. Never point it at a live production data directory.
## Move from Docker
Take a tested [backup](https://pds.linkjar.io/operate/backup/), stop the old server, and preserve the complete data directory and every secret. Review the [authentication limits on rollback](https://pds.linkjar.io/operate/update/#roll-back).
Copy the stopped data to `/var/lib/linkjar-pds`, then assign it to `linkjar-pds:linkjar-pds`. Change container paths such as `/app/data` to host paths in the environment. Preserve external database and blob-store settings. Run [native verification](https://pds.linkjar.io/operate/cli/#native-services) before starting. Only one server may use the data, including copies on different hosts.
Next: [verify the public setup](https://pds.linkjar.io/start/verify/), then [create an account](https://pds.linkjar.io/start/first-account/). Use the operator guides for [updates](https://pds.linkjar.io/operate/update/), [backups](https://pds.linkjar.io/operate/backup/), and [monitoring](https://pds.linkjar.io/operate/monitoring/).
# Install with Docker Compose
> Get the Compose file, fill in the secrets, start the server and Caddy.
[Source](https://pds.linkjar.io/start/install/)
For an installation without Docker, use the [Nix package, NixOS service, or native binary](https://pds.linkjar.io/start/native/).
The deployment is four files from the repository: a Compose file with the server and Caddy, a Caddyfile, and two example environment files.
The Compose template pins `caddy:2.11.7-alpine` by image digest. Updating the repository does not update an already running edge; apply the changed template during the deployment’s normal update process.
* deploy/compose/
* compose.yml the server and Caddy
* Caddyfile certificates on demand, for the server and each handle
* example.env for Compose: the image, the name, your email
* example.pds.env for the server: secrets and settings
1. Get the files onto the host.
```bash
git clone --depth 1 https://github.com/linkjar/pds.git
```
```bash
cd pds/deploy/compose
```
2. Choose the image.
* Published image
Every push to `main` publishes `ghcr.io/linkjar/pds-server` for `amd64` and `arm64`. Resolve the `main` tag to a digest, and pin the digest: a digest names one build, where a tag moves.
```bash
docker buildx imagetools inspect ghcr.io/linkjar/pds-server:main --format '{{.Manifest.Digest}}'
```
It prints `sha256:…`. The image is `ghcr.io/linkjar/pds-server@sha256:…`.
* Build from source
The repository’s `Dockerfile` builds the server with the pinned toolchain. Run this from the repository root, on the host or on a workstation with the same architecture. The first build takes a few minutes.
```bash
docker build -t linkjar-pds:local .
```
The image is `linkjar-pds:local`.
3. Write `.env`. Compose reads it; the server does not.
```bash
cp example.env .env
```
Set `PDS_IMAGE` to the image, `PDS_HOSTNAME` to `pds.example.com` and `ACME_EMAIL` to `operator@example.com`.
4. Write `pds.env`, the server’s secrets and settings.
```bash
cp example.pds.env pds.env
```
```bash
chmod 600 pds.env
```
Generate the three secrets and paste each into its line. Keep them. Sessions and the identities of the accounts depend on them, and a lost rotation key is lost control of every account’s DID.
The JWT secret:
```bash
openssl rand --hex 16
```
The admin password:
```bash
openssl rand --hex 16
```
The PLC rotation key:
```bash
openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32
```
The rest of the file holds settings with their usual values: the data directory inside the container, the public PLC directory, the Bluesky AppView and relay, and `PDS_INVITE_REQUIRED=true`. [Environment variables](https://pds.linkjar.io/configure/environment/) explains each.
5. Create the data directory. The server runs as user id 1000 in the image, so the directory belongs to that id.
```bash
sudo install -d -o 1000 -g 1000 data
```
6. Check the configuration without starting the server.
```bash
docker compose run --rm pds linkjar-pds check-config
```
It prints `the configuration is valid`. A missing or malformed variable is named instead; fix it and run the check again.
7. Start the server and Caddy.
```bash
docker compose up -d
```
```bash
docker compose logs pds
```
The server logs JSON lines. A line with `"message":"serving"` and the server’s DID means it is up. Caddy asks for the server’s certificate the first time a client connects.
Next: [check that it works](https://pds.linkjar.io/start/verify/) from outside the host.
# Check that it works
> Four requests from outside the host, each with the answer to expect, and the smoke test that makes them all.
[Source](https://pds.linkjar.io/start/verify/)
Run these from your workstation, not from the host, so that DNS, the firewall and the certificate are all in the path.
## The health route
```bash
curl -s https://pds.example.com/xrpc/_health
```
It answers `{}` with status 200, or `{"version":"…"}` when `PDS_VERSION` is set. A 503 with `"error":"Service Unavailable"` means the account database did not answer: read the logs.
## What the server says about itself
```bash
curl -s https://pds.example.com/xrpc/com.atproto.server.describeServer
```
The answer names the server’s DID, `did:web:pds.example.com`, lists the handle suffix `.pds.example.com` under `availableUserDomains`, and says `"inviteCodeRequired":true`.
## The OAuth metadata
```bash
curl -s https://pds.example.com/.well-known/oauth-authorization-server
```
A JSON document whose `issuer` is `https://pds.example.com`. Apps that sign in with OAuth, the Bluesky app among them, read it first.
## The certificate guard
The supplied Compose and native Caddy configurations ask the server before requesting a certificate for a name, so that only the server’s name and the handles of its accounts get one. Ask the same question:
```bash
curl -s "https://pds.example.com/tls-check?domain=pds.example.com"
```
It answers `{"success":true}`. A name that nobody hosts gets a 404, and a stranger who points a name at your host gets no certificate from it.
## Everything at once
The repository’s smoke test makes the requests above, subscribes to the firehose, and reports one line per check. It needs Node 24 and pnpm on your workstation.
```bash
cd pds/parity && pnpm install
```
```bash
pnpm parity smoke https://pds.example.com
```
Every line starts with `ok`, and the last says how many checks passed.
With `--write` and `PDS_ADMIN_PASSWORD` in the environment, the test also creates an account, posts, uploads an image, makes an app password, and deletes the account again. The account’s DID stays in the PLC directory after the deletion, as every DID does.
```bash
read -s PDS_ADMIN_PASSWORD && export PDS_ADMIN_PASSWORD
```
```bash
pnpm parity smoke https://pds.example.com --write
```
Next: [create the first account](https://pds.linkjar.io/start/first-account/).
# Create the first account
> An invite code, the Bluesky app, the first post, and when the rest of the network sees it.
[Source](https://pds.linkjar.io/start/first-account/)
Sign-up needs an invite code, so that strangers cannot fill the server. The admin password creates codes.
## Create an invite code
On the host, with `PDS_ADMIN_PASSWORD` from your runtime secret file in the environment:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"useCount": 1}' https://pds.example.com/xrpc/com.atproto.server.createInviteCode
```
It answers `{"code":"pds-example-com-xxxxx-xxxxx"}`. A code with a `useCount` of 5 admits five accounts.
## Sign up from the Bluesky app
1. Open the app and choose **Create account**.
2. Under **Hosting provider**, choose **Custom** and enter `https://pds.example.com`.
3. Enter the invite code, an email address, a password and a handle. The handle becomes `alice.pds.example.com`.
4. Post something.
With the supplied Caddy configuration, the first request for `alice.pds.example.com` triggers certificate issuance. It can take a few seconds.
## Or sign up from the terminal
```bash
curl -s -H 'content-type: application/json' -d '{"email":"alice@example.com","handle":"alice.pds.example.com","password":"…","inviteCode":"pds-example-com-xxxxx-xxxxx"}' https://pds.example.com/xrpc/com.atproto.server.createAccount
```
The answer holds the account’s `did`, its `handle` and a session. Sign in with the handle and the password from any app.
## Check the handle
```bash
curl -s https://alice.pds.example.com/.well-known/atproto-did
```
It prints the account’s DID, `did:plc:…`. Apps resolve handles this way.
## When posts reach other people
A post appears in other people’s timelines once the relay at `bsky.network` crawls the host. The server asks it to with the first write after a start, and then at most once in twenty minutes. The relay’s own status shows the connection:
```bash
curl -s "https://bsky.network/xrpc/com.atproto.sync.getHostStatus?hostname=pds.example.com"
```
The answer has `"status":"active"` and a `seq` that moves with each write.
> **Keep invites on**
>
> `PDS_INVITE_REQUIRED=false` opens sign-up to anyone who finds the server. Leave it on and hand out codes; [accounts and invites](https://pds.linkjar.io/operate/accounts/) has the rest of the invite commands.
Next: set up [email](https://pds.linkjar.io/configure/email/) so that confirmation and password-reset mail arrives, and [back up](https://pds.linkjar.io/operate/backup/) the data directory and all configuration and secrets.
# Blob storage
> Images and videos on the disk, or in an S3-compatible bucket.
[Source](https://pds.linkjar.io/configure/blob-storage/)
A blob is an image, a video or any other file an account uploads. By default blobs are files under the data directory. For a host with a small disk, or for a bucket that is backed up and replicated for you, the server can keep them in an S3-compatible store instead.
## On the disk
`PDS_BLOBSTORE_DISK_LOCATION` names the directory, `blocks` under the data directory in both installation examples. The layout is the reference server’s:
| Path | Content |
| ------------------------ | ----------------------------------------------------- |
| `blocks//` | a stored blob |
| `tempt//` | an upload that waits for the record that refers to it |
| `quarantine//` | a blob of a taken-down account or record |
`tempt` and `quarantine` sit beside `blocks`, in the data directory. `PDS_BLOB_UPLOAD_LIMIT` caps one upload, in bytes; the example file sets 100 MiB.
## In an S3-compatible bucket
Set the bucket and remove `PDS_BLOBSTORE_DISK_LOCATION`: the server refuses both at once.
```dotenv
PDS_BLOBSTORE_S3_BUCKET=pds-blobs
PDS_BLOBSTORE_S3_REGION=auto
PDS_BLOBSTORE_S3_ENDPOINT=https://.r2.cloudflarestorage.com
PDS_BLOBSTORE_S3_FORCE_PATH_STYLE=true
PDS_BLOBSTORE_S3_ACCESS_KEY_ID=…
PDS_BLOBSTORE_S3_SECRET_ACCESS_KEY=…
```
The example is Cloudflare R2. MinIO, Backblaze B2, Wasabi and AWS S3 work the same way; AWS needs no endpoint. The rules:
* The region and both halves of the credentials are needed at start. Without a region the server reads `AWS_REGION` or `AWS_DEFAULT_REGION`; without credentials it reads `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_SESSION_TOKEN`. It reads no profile file and no instance role.
* With `FORCE_PATH_STYLE`, or an endpoint that is an IP address, the bucket is the first segment of the path. Otherwise it is a label of the host.
* `PDS_BLOBSTORE_S3_UPLOAD_TIMEOUT_MS` bounds one upload from its first byte to its last, 20 seconds by default.
Objects are named as the reference server names them, `blocks//`, `tmp//` and `quarantine//`, so a bucket the reference server wrote is served as it is. An upload goes to the bucket as the client sends it, in one request below 8 MiB and in parts of 8 MiB above, so the server holds one part in memory and writes nothing to the disk. A request the store refuses with 429 or a 5xx is sent three times at most.
## Check a store
`verify` lists the objects of each account and compares them with the blob index of its repository. It changes nothing in the bucket.
For a native service, run `pds verify` with the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services). For Compose:
```bash
docker compose run --rm pds linkjar-pds verify
```
Moving blobs between the disk and a bucket is a copy with a tool of your choice while the server is stopped; the names are the same on both sides.
# Email
> The mail the server sends, the SMTP URL it needs, and how to test it.
[Source](https://pds.linkjar.io/configure/email/)
The server sends mail for five things: to confirm an email address, to reset a password, to change the address, to delete the account, and to sign a PLC operation. Each mail carries a token, and the flow waits for it.
Without SMTP the server sends nothing. A server of one can go without; before you invite other people, set it up, or nobody can reset a forgotten password.
## Set the SMTP URL
Add these settings to your runtime environment file:
```dotenv
PDS_EMAIL_SMTP_URL=smtps://user:password@smtp.example.com/
PDS_EMAIL_FROM_ADDRESS=pds@example.com
```
The URL names the scheme, the credentials and the host. `smtps://` is TLS on port 465; `smtp://` on port 587 upgrades to TLS. Add a port after the host when the provider uses another one.
> **Percent-encode the password**
>
> A password with a character that means something in a URL, such as `@`, `:`, `/` or `#`, must be percent-encoded. `p@ss` becomes `p%40ss`.
A sender address at the server’s own domain, or at a domain whose SPF and DKIM records name the provider, keeps the mail out of spam folders.
Restart after the change. For NixOS or the native systemd example:
```bash
sudo systemctl restart linkjar-pds
```
For Compose:
```bash
docker compose up -d
```
## Test it
Ask for a password reset for an account whose address you can read:
```bash
curl -s -H 'content-type: application/json' -d '{"email":"alice@example.com"}' https://pds.example.com/xrpc/com.atproto.server.requestPasswordReset
```
The answer is empty with status 200, and the mail arrives within a minute. A mail that gates a flow is sent before the request is answered, so an SMTP failure fails the request, with the reason in the logs:
For a native service, use `sudo journalctl -u linkjar-pds`. For Compose, use `docker compose logs pds`. See [monitoring](https://pds.linkjar.io/operate/monitoring/#logs).
## Mail from a moderation service
A moderation service can send mail to an account through the admin API. It goes out with `PDS_MODERATION_EMAIL_SMTP_URL` and `PDS_MODERATION_EMAIL_ADDRESS` when they are set, and with the server’s own sender otherwise.
# Environment variables
> Every setting a self-hoster is likely to touch, grouped by what it does, with the reference server's defaults.
[Source](https://pds.linkjar.io/configure/environment/)
The server reads configuration from its process environment. Compose loads `pds.env`; native systemd examples load `/etc/linkjar-pds/pds.env`. The binary does not load either file itself. It uses the reference server’s variable names. The tables identify LinkJar defaults and safety restrictions; new settings are at the end.
An invalid value stops the server at start with a message that names the variable. An unknown `PDS_*` variable is a warning. `check-config` runs the same checks without starting anything:
For native services, use the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services):
```bash
pds check-config
```
For Compose:
```bash
docker compose run --rm pds linkjar-pds check-config
```
## The server
| Variable | Meaning | Default |
| ---------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------ |
| `PDS_HOSTNAME` | The server’s public name. **Required.** | |
| `PDS_PORT` | The port the public listener binds. | `2583` natively; `3000` in the image |
| `PDS_SERVICE_DID` | The server’s own DID. | `did:web:` and the hostname |
| `PDS_SERVICE_HANDLE_DOMAINS` | The suffixes of hosted handles, each with a leading dot, separated by commas. | `.` and the hostname |
| `PDS_VERSION` | Shown by the health route. | unset |
| `PDS_CONTACT_EMAIL_ADDRESS` | Shown by `describeServer`. | unset |
| `PDS_PRIVACY_POLICY_URL`, `PDS_TERMS_OF_SERVICE_URL` | Linked by `describeServer` and on the sign-up page. | unset |
| `PDS_HOME_URL`, `PDS_SUPPORT_URL` | Links on the OAuth pages. | unset |
| `PDS_DEV_MODE` | Relaxes checks for local development. Never on a public host. | `false` |
## Secrets
| Variable | Meaning |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PDS_JWT_SECRET` | Signs sessions. **Required.** Changing it signs everyone out. |
| `PDS_ADMIN_PASSWORD` | The password of the `admin` user for the admin API and invite codes. **Required.** |
| `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | The key that signs PLC operations for new accounts and handle changes. Without it the server creates no account. Keep it: it is the control of every account’s DID. |
| `PDS_DPOP_SECRET` | Signs the nonces of OAuth proofs. Optional; set it so that nonces survive a restart. |
| `PDS_RECOVERY_DID_KEY` | A `did:key` added to each new account’s DID document as a further rotation key, for recovery with a key kept elsewhere. Optional. |
## Storage
| Variable | Meaning | Default |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `PDS_DATA_DIRECTORY` | The data directory. Native examples use `/var/lib/linkjar-pds`; Compose mounts it at `/app/data`. | |
| `PDS_BLOBSTORE_DISK_LOCATION` | Where blobs go on disk, usually `blocks` under the data directory. | |
| `PDS_BLOBSTORE_S3_*` | An S3-compatible store in place of the disk. [Blob storage](https://pds.linkjar.io/configure/blob-storage/) has the list. | |
| `PDS_BLOB_UPLOAD_LIMIT` | The largest blob, in bytes. The example file sets 100 MiB. | 5 MiB |
| `PDS_ACTOR_STORE_CACHE_SIZE` | How many accounts’ databases stay open at once. | `100` |
| `PDS_MAX_REPO_IMPORT_SIZE` | The largest repository import body, in bytes. Must be positive; parsing uses additional memory. | 64 MiB (67,108,864 bytes) |
| `PDS_ACCEPTING_REPO_IMPORTS` | Whether accounts may import a repository, as in a migration from another server. | `true` |
| `PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT` | Hands SQLite checkpoints to a backup tool such as Litestream. | `false` |
## Identity
| Variable | Meaning | Default |
| -------------------------------------------------- | --------------------------------------------------------------------------- | ----------------------- |
| `PDS_DID_PLC_URL` | The PLC directory where new DIDs are registered. | `https://plc.directory` |
| `PDS_HANDLE_BACKUP_NAMESERVERS` | Nameservers to ask when the system resolver cannot verify a handle. | unset |
| `PDS_ID_RESOLVER_TIMEOUT` | How long a handle or DID lookup may take, in milliseconds. | `3000` |
| `PDS_DID_CACHE_STALE_TTL`, `PDS_DID_CACHE_MAX_TTL` | How long a cached DID document is served before and after a refresh is due. | 1 hour, 1 day |
## The network
| Variable | Meaning | Usual value |
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID` | The AppView that serves feeds, notifications and preferences for the Bluesky app. Without them the app cannot load its settings. | `https://api.bsky.app`, `did:web:api.bsky.app` |
| `PDS_REPORT_SERVICE_URL`, `PDS_REPORT_SERVICE_DID` | Where `createReport` is forwarded. | `https://mod.bsky.app`, `did:plc:ar7c4by46qjdydhdevvrndac` |
| `PDS_CRAWLERS` | The relays the server asks to crawl it, separated by commas. | `https://bsky.network` |
| `PDS_MAX_SUBSCRIPTION_BUFFER` | How many events a slow firehose subscriber may fall behind before the server drops it. | `500` |
| `PDS_REPO_BACKFILL_LIMIT_MS` | How far back a firehose subscriber may ask for events, in milliseconds. | 3 days |
| `PDS_PROXY_HEADERS_TIMEOUT` | Total upstream proxy deadline, including the response body, in milliseconds. | `10000` |
| `PDS_DISABLE_SSRF_PROTECTION` | Allows private OAuth metadata destinations only with `PDS_DEV_MODE=true`. Production startup rejects it. | `false` |
Untrusted DID, proxy, handle and client-metadata destinations must use public HTTPS on port 443. The connector checks the actual destination addresses, refuses redirects and ignores environment proxies. Configured service URLs, including PLC and AppView, remain trusted and can use private networks. Keep development mode off on a public host.
Response caps are fixed per operation: DID/PLC 512 KiB, OAuth metadata 256 KiB, MCP metadata 64 KiB, external handle files 4 KiB, and proxy errors 64 KiB. `PDS_FETCH_MAX_RESPONSE_SIZE` is not an implemented setting.
## Invites and limits
| Variable | Meaning | Default |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `PDS_INVITE_REQUIRED` | Whether sign-up needs an invite code. | `true` in the example file |
| `PDS_INVITE_EPOCH`, `PDS_INVITE_INTERVAL` | The reference server’s per-account invites: from the epoch on, each account earns one code per interval, in milliseconds. | unset, no codes earned |
| `PDS_RATE_LIMITS_ENABLED` | The reference server’s rate limits, by client address and by account. | `true` |
| `PDS_RATE_LIMIT_BYPASS_KEY`, `PDS_RATE_LIMIT_BYPASS_IPS` | A header value, and addresses, that bypass the limits. | unset |
| `PDS_HCAPTCHA_SITE_KEY`, `PDS_HCAPTCHA_SECRET_KEY`, `PDS_HCAPTCHA_TOKEN_SALT` | hCaptcha on the sign-up page. All three or none. | unset |
The process also admits at most 8 uploads, 2 imports, 8 streamed exports, 32 firehose connections and 64 ordinary blocking jobs. Exhaustion returns 503 `ServerBusy`; a rate-limit bypass does not bypass these limits. Audit writes use four separate workers and wait for capacity. These limits are fixed in the implementation.
Request-body reads allow 15 seconds without progress and 300 seconds total; expiry returns 408 `RequestTimeout`. Exports have the same total deadline and a 15-second queue stall limit. Firehose sends may stall for 15 seconds; incoming frames and messages are capped at 64 KiB. Clients must discard an incomplete export and retry later. Refused bodies are drained for at most five seconds or the byte cap; an oversized body still returns 413 if draining times out.
## Mail
| Variable | Meaning |
| --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `PDS_EMAIL_SMTP_URL` | The SMTP server, as a URL with the credentials. [Email](https://pds.linkjar.io/configure/email/) has the shape. |
| `PDS_EMAIL_FROM_ADDRESS` | The sender of the server’s mail. |
| `PDS_MODERATION_EMAIL_SMTP_URL`, `PDS_MODERATION_EMAIL_ADDRESS` | The sender of mail a moderation service sends to accounts through the admin API. Optional. |
## Branding
`PDS_LOGO_URL`, `PDS_PRIMARY_COLOR`, `PDS_ERROR_COLOR`, `PDS_WARNING_COLOR`, `PDS_SUCCESS_COLOR`, `PDS_INFO_COLOR`, `PDS_BACKGROUND_LIGHT_URL` and `PDS_BACKGROUND_DARK_URL` style the sign-in and sign-up pages, as on the reference server.
## New in LinkJar PDS
| Variable | Meaning | Default |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| `PDS_PROFILE` | `stock` for the reference server’s behaviour, `linkjar` for LinkJar’s sign-in providers and policies. [Profiles](https://pds.linkjar.io/configure/profiles/). | `stock` |
| `PDS_METRICS_ADDRESS` | The private listener for Prometheus metrics. [Logs, health and metrics](https://pds.linkjar.io/operate/monitoring/). | unset, no listener |
| `PDS_OPS_ADDRESS`, `PDS_OPS_CLIENT_IDS` | The private listener of the operations console, and the console’s client id. [Console and MCP server](https://pds.linkjar.io/scale/sidecars/). | unset |
| `PDS_AUDIT_KEY_ED25519_PRIVATE_KEY_HEX` | The key that signs audit checkpoints. [Audit log](https://pds.linkjar.io/operate/audit-log/). | unset, checkpoints unsigned |
| `PDS_AUDIT_CHECKPOINT_REPO` | The DID of the account on this server that publishes the checkpoints. | unset |
| `PDS_POSTGRES_URL`, `PDS_POSTGRES_SCHEMA_PREFIX` | The shared databases on Postgres instead of SQLite files. [Postgres](https://pds.linkjar.io/scale/postgres/). | unset, `pds` |
| `PDS_ENTRYWAY_*`, `PDS_MEMBER_*` | A member host, or an entryway. [Entryway](https://pds.linkjar.io/scale/entryway/). | unset |
| `PDS_MCP_CLIENT_IDS`, `PDS_OAUTH_KNOWN_CLIENTS_FILE` | The MCP servers of this server, and OAuth clients known without a fetch. | unset |
| `LOG_LEVEL` | The log filter: `info`, `debug`, or a filter such as `info,pds_xrpc=debug`. | `info` |
The [specification’s Appendix C](https://github.com/linkjar/pds/blob/main/docs/SPEC.md#appendix-c-configuration) lists every accepted variable, including the ones this page leaves out.
# Handles and certificates
> Hosted handles under the server's name, handles on a domain of the account's own, and how Caddy decides which names get a certificate.
[Source](https://pds.linkjar.io/configure/handles/)
A handle is a domain name that resolves to an account’s DID. The server hosts handles under its own name, and an account can use a domain of its own instead.
## Hosted handles
`PDS_SERVICE_HANDLE_DOMAINS` lists the suffixes, each with a leading dot and separated by commas. The default is the server’s own name, so handles are `alice.pds.example.com`. Each suffix needs a wildcard DNS record at the host and a certificate for each handle.
To offer a second suffix, such as `.example.org`:
1. Add `.example.org` to `PDS_SERVICE_HANDLE_DOMAINS`: `.pds.example.com,.example.org`.
2. Point `*.example.org` at the host.
3. Add the names to the site block of the Caddyfile: `{$PDS_HOSTNAME}, *.{$PDS_HOSTNAME}, *.example.org`.
The server answers `/.well-known/atproto-did` for each hosted handle by the request’s `Host` header. Handles cannot end in `.alt`, `.arpa`, `.example`, `.internal`, `.invalid`, `.local`, `.localhost` or `.onion`, and the reference server’s reserved names are refused.
## Certificates on demand
Caddy does not hold a wildcard certificate. It asks Let’s Encrypt for a certificate the first time a client connects to a name, and before it asks, it calls the server’s `/tls-check?domain=`. The server says yes for its own name and for the handle of each active account, and no for every other name. A stranger who points a name at your host gets no certificate from it, and the server never uses up the rate limits of Let’s Encrypt on names it does not host.
The first request for a new handle waits a few seconds for the certificate. A deactivated or deleted account’s handle gets no new certificate.
## A handle on the account’s own domain
An account can use `alice.com` as its handle. Alice proves the domain is hers in one of two ways, then changes the handle in the app’s settings:
* A DNS record `_atproto.alice.com` of type `TXT` with the value `did=did:plc:…`, or
* the file `https://alice.com/.well-known/atproto-did` with the DID as its body.
The server checks DNS first and the file second; when both exist and disagree, DNS wins. The old hosted handle is released. The AT Protocol’s [handle guide](https://atproto.com/guides/identity#handles) has the detail for people on your server.
> **Keep the server off a shared domain**
>
> Serve the PDS on a domain of its own, not on a subdomain of a site that also serves a web app with an OAuth client. The blobs and the authorization pages of the server would otherwise share a parent domain with the app’s cookies.
# Profiles
> The stock profile reproduces the reference server. The linkjar profile adds LinkJar's sign-in providers and policies.
[Source](https://pds.linkjar.io/configure/profiles/)
Behaviour that varies per operator sits behind extension points in the server, and `PDS_PROFILE` selects a set of them. Everything else, from the repository engine to the firehose, is the same in both profiles.
## `stock`
The default. The server behaves as the reference server does: sign-up with an email address, a password and an invite code; sign-in with the password or an app password, or through OAuth; the reference server’s mail.
Most self-hosters want this one.
## `linkjar`
The profile LinkJar runs on its own hosts. It adds:
* Sign-in with Apple, Google and GitHub, from the sign-up and sign-in pages. Each provider needs `PDS_EXTERNAL__CLIENT_ID` and `PDS_EXTERNAL__CLIENT_SECRET`, for `APPLE`, `GOOGLE` and `GITHUB`.
* A handle policy: a handle suggested from the display name or the email address, 3 to 18 characters, with a suffix on collision, and one rename of a hosted handle within 30 days.
* An account page at `/account` with the sign-in methods, the sessions and the devices of an account, and a receipt of the sign-up that the LinkJar apps read.
* LinkJar’s mail templates, with a text alternative and no tracking.
* hCaptcha on the sign-up page when `PDS_HCAPTCHA_SITE_KEY`, `PDS_HCAPTCHA_SECRET_KEY` and `PDS_HCAPTCHA_TOKEN_SALT` are set. With hCaptcha on, new accounts come through the sign-up page only, and `createAccount` from the API is closed to them.
* Operator and moderator roles for the [console](https://pds.linkjar.io/scale/sidecars/).
The [specification’s section 13](https://github.com/linkjar/pds/blob/main/docs/SPEC.md#13-the-linkjar-profile) has every rule. Switch profiles with a restart; the data directory is the same for both.
# Use these docs with AI
> Use llms.txt, focused Markdown bundles, or a single guide with your chosen assistant.
[Source](https://pds.linkjar.io/connect/ai-guidance/)
Use **Copy page** above any guide to copy its Markdown, including the source URL and command examples. **Use with AI** offers the documentation index, the full documentation, and a link to the current page. Code blocks have their own copy buttons; copying a command does not include the language or file title.
These controls copy public documentation to your clipboard. They do not send it to an AI provider. Choose what to paste into your assistant.
## Choose how much context to share
| You need | Use |
| ------------------------------------------------- | ------------------------------------------------------------------------------------ |
| Help with one task | Copy that guide, such as [native installation](https://pds.linkjar.io/start/native/) |
| Help finding the right guide | [Documentation index](https://pds.linkjar.io/llms.txt) |
| A new server or a different installation method | [Setup bundle](https://pds.linkjar.io/llms-setup.txt) |
| Backups, updates, migration, or troubleshooting | [Operations bundle](https://pds.linkjar.io/llms-operations.txt) |
| Connecting an AI client or the operations console | [Clients bundle](https://pds.linkjar.io/llms-clients.txt) |
| Context across the whole project | [Complete documentation](https://pds.linkjar.io/llms-full.txt) |
The complete export can be large. Start with the relevant page when your assistant has a small context window. If copying is unavailable in your browser, use **View Markdown** and copy the text directly.
## Give an assistant the documentation URL
If your assistant can fetch web pages, give it the index URL. It can choose the relevant guides from there:
**Documentation index**
```text
https://pds.linkjar.io/llms.txt
```
If it cannot fetch URLs, download a bundle and attach the file, or paste the copied text. This example saves the setup guides:
**Download the setup bundle**
```bash
curl --fail --location --output linkjar-pds-setup.md \
https://pds.linkjar.io/llms-setup.txt
```
Every guide also has a **View Markdown** link. For example, [`/start/native.md.txt`](https://pds.linkjar.io/start/native.md.txt) is the native installation guide. The exports include source links and language-labeled code blocks. They are generated from the same content as this site when it is built.
The HTML identifies each page’s Markdown alternative and links to `llms.txt` for tools that support discovery. Support varies by assistant; supplying the URL or file directly is the most reliable way to provide the context.
## A starting prompt
Copy this prompt and the relevant installation guide into your chosen assistant:
**Plan a PDS installation**
```text
Help me set up LinkJar PDS using the attached official documentation.
First ask whether this is a new installation or an existing data directory.
Ask for my OS, CPU architecture, domain, and preferred installation method.
Use the documented settings and commands, and cite the relevant guides.
Explain which checks are local and which require testing from another host.
Prepare a plan before changing files, services, DNS, or firewall rules.
Keep credentials and private keys out of the conversation and logs.
Generate and store secrets locally using the documented protected files.
Stop if existing data or an unsupported platform changes the plan.
After setup, verify configuration, HTTPS, health, and server metadata.
Explain what remains unverified, including email delivery and restore tests.
```
Share redacted error messages when you need help. Keep runtime environment files, passwords, private keys, and account exports on the host or in your secret manager. Review the assistant’s proposed commands before running them.
## Checks you can run today
The server already provides `check-config` and `health`. Use the [operator-command helper](https://pds.linkjar.io/operate/cli/) to run them with the service’s actual environment. Then follow [verify the setup](https://pds.linkjar.io/start/verify/) for external HTTPS and metadata checks.
`check-config` validates configuration and required serving secrets. It does not prove that DNS, inbound networking, SMTP delivery, or backups work.
## Installation help and MCP access
These are separate uses of AI. An assistant can help you follow the manual installation guide. The [MCP sidecar](https://pds.linkjar.io/connect/mcp/) connects an AI client to records in an account after sign-in; it has no host-installation tools.
The supported setup paths are [NixOS or a native binary](https://pds.linkjar.io/start/native/) and [Docker Compose](https://pds.linkjar.io/start/install/). Neither requires an LLM or a model-provider account.
# Operations console
> Run the console beside a native PDS, grant an operator role, and connect privately through an SSH tunnel.
[Source](https://pds.linkjar.io/connect/console/)
The operations console shows accounts, sessions, audit events, and live server state. Operators can take supported actions with a recorded reason. It calls the PDS’s private operations API; it does not open the server’s database.
Use an SSH tunnel to reach it. The console currently requires an HTTP loopback URL and does not support a public console hostname.
## Build the console
Follow [the sidecar build commands](https://pds.linkjar.io/reference/binaries/#build-the-sidecars). Keep the generated `assets/` directory next to `linkjar-pds-console` when you install it. The PDS Nix package and portable archives do not include the console.
For containers, use the [Compose console guide](https://pds.linkjar.io/scale/sidecars/#the-operations-console). The examples below assume native services on one Linux host.
## Connect it to the PDS
Enable the private operations listener in the PDS service environment:
**PDS service environment**
```dotenv
PDS_OPS_ADDRESS=127.0.0.1:2584
```
Configure a separate unprivileged console service:
**Console service environment**
```dotenv
CONSOLE_ADDRESS=127.0.0.1:2585
CONSOLE_PUBLIC_URL=http://127.0.0.1:2585
CONSOLE_PDS_PUBLIC_URL=https://pds.example.com
CONSOLE_PDS_INTERNAL_URL=http://127.0.0.1:2583
CONSOLE_OPS_URL=http://127.0.0.1:2584
```
Run `linkjar-pds-console` without arguments, with these settings loaded by your service manager. Adapt the [native systemd guide](https://pds.linkjar.io/start/native/#linux-binary-with-systemd) for its executable, environment file, and service user. The console does not need the PDS’s secrets or data directory.
Read the client ID from the console’s startup log. Add it to `PDS_OPS_CLIENT_IDS` in the PDS environment, preserving any existing comma-separated entries. For the exact loopback URL above, the ID is:
**PDS service environment — console client allowlist**
```dotenv
PDS_OPS_CLIENT_IDS=http://localhost?redirect_uri=http%3A%2F%2F127.0.0.1%3A2585%2Foauth%2Fcallback&scope=atproto
```
Restart the PDS after updating its settings. If you change the console’s browser port, use the new client ID from its log.
## Grant an operator role
Create the operator’s PDS account first. Only the PDS admin password can grant a role. Use the private operations listener on the server host, and supply the account’s real DID:
**Run on the PDS host — curl prompts for the admin password**
```bash
curl --fail-with-body --user admin \
--header 'X-Ops-Reason: first operator' \
--header 'Content-Type: application/json' \
--data '{"did":"REPLACE_WITH_ACCOUNT_DID","role":"operator"}' \
http://127.0.0.1:2584/xrpc/internal.ops.grantRole
```
`operator` permits operations other than granting roles. Use `moderator` for the more restricted moderation role. Keep the operations port off the public network.
## Open the console
From your own computer, leave this SSH session open:
**Forward the console to your computer**
```bash
ssh -N -L 2585:127.0.0.1:2585 operator@pds.example.com
```
Open `http://127.0.0.1:2585` in your browser. Sign in on the PDS with the account that holds the operator role. Do not use the admin password as a console login.
For a local health check, run `linkjar-pds-console health` with the console’s environment. Restarting the console signs operators out because sessions are stored in memory.
## If sign-in fails
Check that the browser URL matches `CONSOLE_PUBLIC_URL`, the PDS allows the logged client ID, and the account has a role. Verify that the console service can reach `CONSOLE_OPS_URL`. When using containers, use the Compose network addresses instead of these native loopback examples.
Next: [monitor the server](https://pds.linkjar.io/operate/monitoring/) and [review the audit log](https://pds.linkjar.io/operate/audit-log/).
# Connect an AI client with MCP
> Run the optional MCP server and connect an AI client to your PDS account with OAuth and scoped permissions.
[Source](https://pds.linkjar.io/connect/mcp/)
The MCP server lets an AI client read your account’s records and, when you allow it, write to selected collections. Your chosen AI application runs the model. The PDS and MCP server do not need an LLM API key.
Use a client that supports **remote Streamable HTTP with OAuth**. This server does not expose a local stdio transport. Client support and setup screens vary; check your client’s documentation for that combination.
## Connection at a glance
| Setting in your AI client | Value for the example deployment |
| ------------------------- | -------------------------------- |
| Server URL | `https://mcp.example.com/mcp` |
| Transport | Streamable HTTP |
| Authentication | OAuth through the browser |
**MCP server URL — replace the example hostname**
```text
https://mcp.example.com/mcp
```
The AI client connects to the MCP sidecar. The sidecar connects to the PDS through OAuth and authenticated repository APIs. It does not grant shell access, install software, or administer the host.
## Prepare the server
First finish [PDS installation](https://pds.linkjar.io/start/overview/) and [create an account](https://pds.linkjar.io/start/first-account/). Give MCP its own DNS name, such as `mcp.example.com`, pointing to the host that will run it.
[Build `linkjar-pds-mcp`](https://pds.linkjar.io/reference/binaries/#build-the-sidecars) from a reviewed checkout, or build `Dockerfile.mcp`. The portable PDS download does not contain it. The following addresses assume native services on one Linux host.
### Set the environment
Store these settings in a protected runtime environment file. Generate a fresh P-256 private key with your key-management tool and store its 32-byte private scalar as 64 hexadecimal digits. This is a separate MCP client key, not the PDS’s secp256k1 PLC rotation key. Do not paste either key into your AI client.
**MCP service environment**
```dotenv
MCP_ADDRESS=127.0.0.1:2586
MCP_PUBLIC_URL=https://mcp.example.com
MCP_PDS_PUBLIC_URL=https://pds.example.com
MCP_PDS_INTERNAL_URL=http://127.0.0.1:2583
MCP_CLIENT_KEY_P256_PRIVATE_KEY_HEX=REPLACE_WITH_MCP_P256_PRIVATE_KEY
MCP_WRITE_COLLECTIONS=
```
Leave `MCP_WRITE_COLLECTIONS` empty for the initial read-only connection. `MCP_PDS_PUBLIC_URL` must match the PDS’s public OAuth issuer even when the internal connection uses loopback.
### Allow the client at the PDS
Add this metadata URL to the PDS’s `PDS_MCP_CLIENT_IDS` allowlist. Preserve any existing entries; this setting is a comma-separated list.
**PDS service environment**
```dotenv
PDS_MCP_CLIENT_IDS=https://mcp.example.com/oauth-client-metadata.json
```
Restart the PDS through its service manager after updating the setting. If you use `PDS_OAUTH_KNOWN_CLIENTS_FILE`, keep its MCP metadata and public key aligned with the running sidecar.
### Run the sidecar behind HTTPS
Run `linkjar-pds-mcp` without arguments, as a separate unprivileged service. Have the service manager load its protected environment file. On a native Linux host, adapt the [systemd example](https://pds.linkjar.io/start/native/#linux-binary-with-systemd) with a separate service user, the MCP executable path, and its environment file. MCP does not need access to the PDS data directory.
Proxy the **whole MCP origin**, including OAuth discovery and callbacks:
**Caddyfile — native services on the same host**
```caddyfile
mcp.example.com {
reverse_proxy 127.0.0.1:2586
}
```
Keep port `2586` private. For Docker, bind inside the container and proxy through the container network instead of using the native loopback addresses.
Check the public health and discovery routes:
**Verify MCP discovery**
```bash
curl --fail --silent --show-error https://mcp.example.com/health
curl --fail --silent --show-error https://mcp.example.com/.well-known/oauth-protected-resource
curl --fail --silent --show-error https://mcp.example.com/.well-known/oauth-authorization-server
curl --fail --silent --show-error https://mcp.example.com/oauth-client-metadata.json
```
## Connect and try a read
1. Add `https://mcp.example.com/mcp` as a remote server in your AI client.
2. Start the OAuth sign-in flow. Sign in on your PDS’s page and review consent.
3. Ask the client to use `whoami`, then `list_collections`.
4. Try `list_records` on one collection you recognize.
These are the available repository tools:
| Tools | Purpose |
| ---------------------------------------------- | ---------------------------------------------------------------- |
| `whoami` | Identify the signed-in account |
| `describe_repo`, `list_collections` | Inspect the repository and its collections |
| `list_records`, `get_record` | Read records |
| `create_record`, `put_record`, `delete_record` | Write records when the session has permission for the collection |
The client may send tool results to its configured model provider. Choose records and a provider appropriate for the data you intend to share.
## Enable selected writes
Set `MCP_WRITE_COLLECTIONS` to the comma-separated collection NSIDs you want the client to be able to request. For example:
**Example allowlist — use your application's collection**
```dotenv
MCP_WRITE_COLLECTIONS=com.example.note
```
Restart the sidecar, refresh any pinned client metadata at the PDS, and sign in again to request the new permissions. The allowlist alone does not authorize a session: the user must grant access, and the PDS still validates each write. Review `put_record` and `delete_record` calls carefully; they can replace or remove existing records.
## Sessions and troubleshooting
Run one MCP instance. Its registrations, tokens, and sessions are held in memory; a restart ends them. Reconnect and sign in again after a restart. For a service-local check, run `linkjar-pds-mcp health` with the same environment.
| Symptom | Check |
| ------------------------------------------------- | ------------------------------------------------------------------------------ |
| The client only accepts a command and arguments | Use a client with remote Streamable HTTP and OAuth support |
| Discovery succeeds but sign-in fails | Public URLs, the PDS client allowlist, pinned metadata, and the callback route |
| Connection uses a container name on a native host | Change the internal URL to an address reachable from the sidecar |
| Reads work but a write is denied | The collection allowlist and the permissions granted to this session |
| The client loses access after a restart | Reconnect; sessions are intentionally in memory |
For the protocol background, see the official [MCP authorization specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization). For deployment boundaries, see [binaries and ports](https://pds.linkjar.io/reference/binaries/).
# Accounts, invites and moderation
> The admin API with the admin password: invite codes, account details, password and email changes, takedowns and deletion.
[Source](https://pds.linkjar.io/operate/accounts/)
The admin API is the reference server’s. Every call authenticates with HTTP basic auth as `admin` with `PDS_ADMIN_PASSWORD`, and every call is an entry in the [audit log](https://pds.linkjar.io/operate/audit-log/).
The commands below assume `PDS_ADMIN_PASSWORD` in the environment:
```bash
read -s PDS_ADMIN_PASSWORD && export PDS_ADMIN_PASSWORD
```
## Invite codes
One code for one account:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"useCount": 1}' https://pds.example.com/xrpc/com.atproto.server.createInviteCode
```
Ten codes of five uses each:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"codeCount": 10, "useCount": 5}' https://pds.example.com/xrpc/com.atproto.server.createInviteCodes
```
Disable a code that leaked:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"codes": ["pds-example-com-xxxxx-xxxxx"]}' https://pds.example.com/xrpc/com.atproto.admin.disableInviteCodes
```
`PDS_INVITE_REQUIRED=false` opens sign-up to everyone. Leave it on unless you want a public server, and then set up hCaptcha and watch the sign-ups.
## Look up an account
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" "https://pds.example.com/xrpc/com.atproto.admin.getAccountInfo?did=did:plc:…"
```
The answer has the handle, the email address and whether it is confirmed, the invite code the account used, and the codes it has.
## Reset a password or change an address
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"did": "did:plc:…", "password": "…"}' https://pds.example.com/xrpc/com.atproto.admin.updateAccountPassword
```
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"account": "did:plc:…", "email": "alice@example.net"}' https://pds.example.com/xrpc/com.atproto.admin.updateAccountEmail
```
A person who still has access resets their own password from the app, through [email](https://pds.linkjar.io/configure/email/).
Both password reset and admin password update revoke the account’s legacy and OAuth sessions, remembered sign-ins, client grants, pending authorizations, app passwords and outstanding email tokens. The person must sign in again and create replacement app passwords. Member hosts check the entryway on each authenticated request, so recovery takes effect on the next request there too.
Recovery state is part of the account database. Preserve it in [backups](https://pds.linkjar.io/operate/backup/), and check the [rollback limits](https://pds.linkjar.io/operate/update/#roll-back) before using an older build.
## Take an account down
A takedown hides the repository and quarantines its blobs. The account cannot sign in; its data stays until you lift the takedown or delete the account.
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"subject": {"$type": "com.atproto.admin.defs#repoRef", "did": "did:plc:…"}, "takedown": {"applied": true, "ref": "spam"}}' https://pds.example.com/xrpc/com.atproto.admin.updateSubjectStatus
```
Lift it with `"applied": false`. The same method takes down one record, with a `com.atproto.repo.strongRef` subject, or one blob.
## Delete an account
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"did": "did:plc:…"}' https://pds.example.com/xrpc/com.atproto.admin.deleteAccount
```
The repository, the blobs and the sessions are removed. The DID stays in the PLC directory, as every DID does; the account can move to another server later with the same DID. A person deletes their own account from the app, with a token sent by mail.
## Reports
A report from the app goes to the moderation service named by `PDS_REPORT_SERVICE_URL`, Bluesky’s by default. The server keeps no report queue of its own.
## A console
The [operations console](https://pds.linkjar.io/scale/sidecars/) does the above from a page, with a reason recorded for each action, and shows the live firehose subscribers and the audit log.
# Audit log
> What the server records about accounts and operators, how checkpoints make the record tamper-evident, and how to verify a bundle offline.
[Source](https://pds.linkjar.io/operate/audit-log/)
Every action on an account or by an operator is an entry in a log the server cannot rewrite without it showing: a sign-up, a password or email change, a handle change, a deactivation, a deletion, a takedown, an invite created or disabled, and every call to the admin API, with its outcome. Ordinary reads and ordinary writes to a repository are not in it: repository data is already signed, and reads are a traffic log.
Each entry carries the hash of the one before it, and the store refuses updates and deletes. Every five minutes, and at shutdown, the server builds a Merkle tree over the new entries and signs a checkpoint over its root. A checkpoint published into an account’s repository travels the firehose, so a copy exists outside the host.
## Turn on signing
Without a key the log chains its entries and signs nothing. Create a key, 32 random bytes as 64 hexadecimal digits:
```bash
openssl rand -hex 32
```
In the runtime environment file:
```dotenv
PDS_AUDIT_KEY_ED25519_PRIVATE_KEY_HEX=…
PDS_AUDIT_CHECKPOINT_REPO=did:plc:…
```
The repository is your own account on the server. Each checkpoint becomes a record in it, under `io.linkjar.pds.audit.checkpoint`. Without `PDS_AUDIT_CHECKPOINT_REPO` the checkpoints stay in `audit.sqlite`, and nobody outside can compare them.
A key that differs from the one of the last checkpoint is itself logged before it signs, so a key change is visible in the record.
## Seal history
A data directory that existed before the log, one the reference server wrote, has history the log did not see. Seal it once, before the first start of the server on it:
For native services, stop `linkjar-pds` and use the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services):
```bash
pds audit seal
```
For Compose, stop the main container first:
```bash
docker compose run --rm pds linkjar-pds audit seal
```
It prints `sealed accounts as sha256:…` and `signed by ed25519:…`. Keep both lines. The command is refused on a log that has entries.
## Export and verify
For native services:
```bash
umask 077
pds audit export > audit-bundle.json
```
For Compose:
```bash
umask 077
docker compose exec -T pds linkjar-pds audit export > audit-bundle.json
```
The bundle holds the entries, the chain hashes, the inclusion proofs, the checkpoints that cover them and the public keys. Verify it away from the host, with any build of the binary:
```bash
linkjar-pds audit verify audit-bundle.json
```
It recomputes the chain, the trees and the signatures and exits 0, or names the first entry that does not fit and exits 1. The verifier shares nothing with the writer but the entry format.
## Watch it
Two metrics say whether signing works: `pds_audit_unsigned_entries` returns to 0 within five minutes of an entry, and `pds_audit_checkpoint_age_seconds` stays under 600 while there are unsigned entries. [Logs, health and metrics](https://pds.linkjar.io/operate/monitoring/) has the listener.
# Back up and restore
> Back up native and Docker installations, preserve authentication state, and restore with the correct paths and service user.
[Source](https://pds.linkjar.io/operate/backup/)
Keep the complete data directory, all blobs, configuration, and every secret. The Compose deployment uses `data/` and `pds.env`. The native examples use `/var/lib/linkjar-pds` and `/etc/linkjar-pds/pds.env`. Include any storage or key files configured outside those paths, and record the exact source commit or image digest. With S3 or Postgres, back up those stores at the same consistent point too; a local archive cannot include remote data.
The PLC rotation key controls the accounts’ DIDs. The JWT secret signs sessions. For secrets provisioned under `/run/secrets`, preserve their encrypted source and recovery keys so you can reconstruct the runtime file on a fresh host.
## The data directory
| Path | Content | Keep |
| -------------------------------- | ------------------------------------------------------------------------------- | --------------- |
| `account.sqlite` | accounts, passwords, sessions, invites, OAuth state, credential recovery epochs | yes |
| `sequencer.sqlite` | the event log the firehose serves | yes |
| `did_cache.sqlite` | cached DID documents | no, rebuilt |
| `audit.sqlite` | the [audit log](https://pds.linkjar.io/operate/audit-log/) | yes |
| `ops.sqlite` | commits in flight, operator roles, blocked domains | yes |
| `actors///store.sqlite` | an account’s repository, records and blob index | yes |
| `actors///key` | the account’s signing key | yes |
| `actors/reserved_keys/` | signing keys of sign-ups in progress | no |
| `blocks//` | blobs | yes |
| `tempt/`, `quarantine/` | uploads in progress; blobs of taken-down accounts | quarantine, yes |
| `linkjar-pds.lock` | held by the running server | no |
SQLite can keep recent writes in `-wal` files while the server runs. Copying live database, WAL, and SHM files individually does not ensure a consistent backup. Use a cold backup, a coordinated filesystem snapshot, or a supported SQLite backup tool. Do not omit WAL files from a snapshot.
Keep the whole account database, including its `credential_epoch` table. That table prevents tokens issued before password recovery from working again. A restore of an older backup also restores its older credentials, sessions and recovery state. If those credentials were compromised, repeat recovery before reopening the server. On [Postgres](https://pds.linkjar.io/scale/postgres/), the table is part of the account schema.
## A cold backup
Stop the server, archive its state and configuration, then start it. The TLS proxy can return an upstream error during the pause. Keep the server stopped until the archive has completed successfully.
### Native and NixOS examples
For the paths in [native installation](https://pds.linkjar.io/start/native/):
```bash
sudo systemctl stop linkjar-pds &&
sudo sh -c 'umask 077; tar -czf /root/linkjar-pds-backup-$(date +%F-%H%M%S).tar.gz -C / var/lib/linkjar-pds etc/linkjar-pds' &&
sudo systemctl start linkjar-pds
```
The archive is root-readable only and contains the data plus the runtime file under `/etc/linkjar-pds`. If you use another secret path, also back up its recoverable source. Preserve the host flake and lockfile or the systemd unit, TLS proxy configuration, and deployment record. Keep a recoverable copy of the selected binary or its pinned build inputs.
### Docker Compose
From the directory containing `compose.yml`:
```bash
docker compose stop pds &&
sudo sh -c 'umask 077; tar -czf /root/linkjar-pds-backup-$(date +%F-%H%M%S).tar.gz data pds.env .env compose.yml Caddyfile' &&
docker compose start pds
```
Move the archive to protected storage off the host. Encrypt backups and restrict access: they contain account data, passwords, signing keys, and session state. Rehearse a restore before relying on them.
## Continuous replication
LinkJar’s own hosts replicate the SQLite files with [Litestream](https://litestream.io/) to object storage and sync the blobs beside them. With Litestream in charge of checkpoints, set `PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT=true`. Rehearse the restore before you rely on it.
## One account
`export-car` writes an account’s repository as a CAR file, the format every AT Protocol tool reads and the one an account takes to another server.
For native services, use the [command helper](https://pds.linkjar.io/operate/cli/#native-services):
```bash
umask 077
pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > alice.car
```
For Docker:
```bash
umask 077
docker compose exec -T pds linkjar-pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > alice.car
```
Blobs are not in the CAR; they are the files under `blocks//`.
## Restore
Restore on a private host with the PDS service stopped. Install the reviewed build and create its service user before restoring data. Inspect the archive paths, restore them to their intended locations, and keep the secret file restricted to root. Restore external blobs and databases consistently too.
### Native or NixOS
Restore the native data to `/var/lib/linkjar-pds` and the runtime file to `/etc/linkjar-pds/pds.env`, or reconstruct it through your secret manager. Do not start an empty NixOS service against the public hostname during recovery. After restoring, check ownership and run the [native helper](https://pds.linkjar.io/operate/cli/#native-services):
```bash
sudo chown -R linkjar-pds:linkjar-pds /var/lib/linkjar-pds
sudo chmod 0700 /var/lib/linkjar-pds
sudo chmod 0600 /etc/linkjar-pds/pds.env
pds check-config
pds verify
```
Keep native paths in the environment. A restore from Docker needs `/app/data` paths changed to their host equivalents. Do not generate new account secrets.
### Docker Compose
Unpack the Compose backup into its deployment directory. Give the restored data to the container’s user and check it before starting:
```bash
sudo chown -R 1000:1000 data
docker compose run --rm pds linkjar-pds verify
```
For either installation, `verify` reads every repository and compares its records and blobs. Expect `differences 0`. Resolve differences before reopening traffic. Start the selected service, move DNS if needed, and [check it from outside](https://pds.linkjar.io/start/verify/).
The relay resumes at its cursor. A restore from a backup older than the last events the relay saw leaves the relay ahead of the server; the relay then re-crawls the repositories at their next commit.
> **One server per data directory**
>
> Never run two servers on one data directory, on one host or two. The server takes `linkjar-pds.lock` at start and refuses to start when another holds it, but a copy on a second host has its own lock file.
# Command line
> Run operator commands with a native binary, the NixOS service, or Docker Compose.
[Source](https://pds.linkjar.io/operate/cli/)
Every installation uses the same `linkjar-pds` executable and commands. Except for `version`, `help`, and `audit verify`, commands read configuration from the environment. The binary does not automatically load `pds.env`. Use the same data paths, secrets, and service user as the server.
## Native services
The [native installation](https://pds.linkjar.io/start/native/) uses the `linkjar-pds` user, `/var/lib/linkjar-pds`, port `2583`, and `/etc/linkjar-pds/pds.env`. Systemd can load that root-owned file before switching to the service user. Define this shell helper on the host:
```bash
PDS_BIN=/usr/local/bin/linkjar-pds
pds() {
sudo systemd-run --quiet --wait --pipe --collect \
--property=Type=exec \
--property=User=linkjar-pds \
--property=Group=linkjar-pds \
--property=WorkingDirectory=/var/lib/linkjar-pds \
--property=EnvironmentFile=/etc/linkjar-pds/pds.env \
--property=UMask=0077 \
--setenv=PDS_DATA_DIRECTORY=/var/lib/linkjar-pds \
--setenv=PDS_PORT=2583 \
"$PDS_BIN" "$@"
}
```
For the NixOS example, set `PDS_BIN=/run/current-system/sw/bin/linkjar-pds` instead. It installs the same package used by the service on that path. If you changed the runtime file, data path, or port, change the helper too. If public settings live in `services.linkjar-pds.environment`, also pass them with `--setenv=NAME=value`. Use an explicit `SSL_CERT_FILE` when the host’s CA bundle is in a nonstandard location.
This helper uses a temporary service for each command. It waits for completion, returns the command’s exit status, and passes its output to your terminal. It does not start or stop the main PDS service. See the [systemd-run manual](https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html) for these options.
```bash
pds check-config
pds verify --json
```
Do not run a second `serve` through this helper. Stop the main service before `audit seal` or `migrate-storage`. Run commands that write state as the service user so they do not leave root-owned database files.
For a foreground installation, use `linkjar-pds ` directly from the shell that holds its configuration and has access to its data.
## Docker Compose
Compose supplies the environment from `pds.env`. Against the running container:
```bash
docker compose exec pds linkjar-pds verify
```
With the main server stopped, run a command in a separate container:
```bash
docker compose run --rm pds linkjar-pds check-config
```
The configuration check can also run while the server is up. Storage migration and the initial audit seal require the main server to be stopped.
## Commands
| Command | Does |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serve` | Serves the data directory. Run under your service manager. |
| `check-config` | Validates the configuration and exits. Prints `the configuration is valid`. |
| `verify [--json]` | Checks the data directory: each repository against its records and blobs. Reads only; prints a summary with the count of differences, lists each, and exits 1 when there is one. |
| `export-car ` | Writes one repository to standard output as a CAR file. |
| `audit seal` | Begins the audit log with a signed snapshot of the accounts, for a directory with history before the log. Refused on a log with entries. |
| `audit export [ []]` | Writes the audit log, or a range of entries, to standard output as a bundle. |
| `audit verify ` | Checks a bundle offline. Needs no configuration, so it runs on any machine with the binary. Exits 1 on a problem. |
| `migrate-storage --to postgres\|sqlite` | Copies the shared databases between the files of the data directory and Postgres, and compares the two. Runs only while no server does. |
| `reconcile [--remove-orphans]` | At an entryway, compares the accounts with the repositories of the member host. |
| `health` | Asks the server on this host for its health route. Also used by the container health check. |
| `version` | Prints the version. |
Standard output belongs to the result; logs go to standard error. For native services, redirect the helper’s output directly:
```bash
umask 077
pds audit export > audit-bundle.json
pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > account.car
```
For Docker, use `exec -T` so it allocates no terminal:
```bash
umask 077
docker compose exec -T pds linkjar-pds audit export > audit-bundle.json
```
# Migrate from the reference PDS
> Plan a switch from the reference PDS using the existing data directory, with backup and rollback safeguards.
[Source](https://pds.linkjar.io/operate/migrate-from-reference/)
LinkJar PDS can serve a data directory the reference server wrote, with the existing `pds.env`. Check a restored copy before switching the running server. Database compatibility alone does not make an older image a safe rollback target.
This page assumes the reference server’s installer: the data at `/pds`, the settings in `/pds/pds.env`, and a systemd unit named `pds` that runs its Compose file.
This procedure switches the reference Docker deployment to LinkJar’s Compose stack. To run without Docker, also follow the [native cutover steps](https://pds.linkjar.io/start/native/#move-from-docker). Preserve the original data and secrets, adapt host paths and ownership, and run verification with the selected native build before starting it.
## Before the switch
1. Take a [cold backup](https://pds.linkjar.io/operate/backup/#a-cold-backup) of `/pds`.
2. Get the Compose files onto the host, as in [the install](https://pds.linkjar.io/start/install/), and write `.env` with the image and `PDS_DATA_PATH=/pds`.
3. Make `pds.env` from the reference server’s:
```bash
sudo cp /pds/pds.env pds.env && sudo chown $USER pds.env && chmod 600 pds.env
```
Change the two paths to where the Compose file mounts the directory:
```ini
PDS_DATA_DIRECTORY=/app/data
PDS_BLOBSTORE_DISK_LOCATION=/app/data/blocks
```
Leave every other line as it is. The JWT secret, the rotation key, the admin password and the SMTP settings must stay: sessions and the DIDs of the accounts depend on them.
4. Check the configuration:
```bash
docker compose run --rm pds linkjar-pds check-config
```
## The switch
1. Stop the reference server. Two servers must never serve one data directory.
```bash
sudo systemctl disable --now pds
```
2. Check the data directory. `verify` reads every account and prints a summary that ends with `differences 0`:
```bash
docker compose run --rm pds linkjar-pds verify
```
A difference is a fact about the data, not about the switch. Stop here and start the reference server again until you understand it.
3. Seal the history for the [audit log](https://pds.linkjar.io/operate/audit-log/#seal-history), if you have set its key:
```bash
docker compose run --rm pds linkjar-pds audit seal
```
4. Start.
```bash
docker compose up -d
```
Caddy starts with an empty certificate store and fetches a certificate for the server’s name at once, and for each handle at its first request.
5. [Check it from outside](https://pds.linkjar.io/start/verify/). The relay resumes at its cursor; its status for the host goes back to `active` with the first write.
## Plan for rollback
Prefer a forward fix or a validated build that retains LinkJar’s recovery checks. This release adds a `credential_epoch` table to the shared account database and a blob-reference index to actor databases. The reference migration ledger stays unchanged, and older servers can read the layout.
The reference server and older LinkJar images do not enforce credential epochs or the member host’s live session check. They can accept revoked, unexpired legacy tokens after password recovery. Read the [update and rollback guidance](https://pds.linkjar.io/operate/update/#roll-back) before choosing an older image.
Keep the current account database and `credential_epoch` in backups and copies. Do not restore a pre-recovery account database to undo the switch: that can restore old passwords, credentials, and access. Preserve `audit.sqlite` and `ops.sqlite` as well.
> **The relay and the AppView**
>
> The reference server’s `pds.env` already names `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID` and `PDS_CRAWLERS`. Keep them: without the AppView the Bluesky app cannot load an account’s settings on either server.
# Logs, health and metrics
> What the server logs, the health route, the metrics listener, and what to alert on.
[Source](https://pds.linkjar.io/operate/monitoring/)
## Logs
The server logs JSON lines to standard error, one object per line with the time, the level, the message and the fields of the event. Requests carry a request id. The logs never contain a token, a password, an email address or the body of a record.
For NixOS and the native systemd service:
```bash
sudo journalctl -u linkjar-pds -f -o cat
```
For Compose:
```bash
docker compose logs -f pds
```
A foreground binary writes the same JSON to its standard error. Capture it through your service manager rather than discarding it.
`LOG_LEVEL` sets the filter: `info` by default, `debug` for everything, or a filter by crate such as `info,pds_oauth=debug`. It takes effect at the next start.
## Health
```bash
curl -s https://pds.example.com/xrpc/_health
```
Status 200 when the account database answers; 503 with `"error":"Service Unavailable"` when it does not. The container’s health check runs `linkjar-pds health` every ten seconds against the same route, and Caddy waits for the first pass before it starts.
```bash
docker compose ps
```
The `pds` service shows `(healthy)`. For native services:
```bash
sudo systemctl status linkjar-pds
curl --fail http://127.0.0.1:2583/xrpc/_health
```
A running process alone does not establish health. Monitor the HTTP response; there is no container health scheduler in a native installation.
## Metrics
`PDS_METRICS_ADDRESS` starts a private listener in Prometheus text format. Keep it private and outside the public proxy routes.
For a native service, bind directly to loopback in its runtime environment:
```dotenv
PDS_METRICS_ADDRESS=127.0.0.1:9464
```
For Compose only, bind inside the container and publish on host loopback. In `pds.env`:
```dotenv
PDS_METRICS_ADDRESS=0.0.0.0:9464
```
In `compose.yml`, under the `pds` service:
```yaml
ports:
- "127.0.0.1:9464:9464"
```
Then:
```bash
curl -s http://127.0.0.1:9464/metrics
```
| Metric | What it is |
| ------------------------------------------ | ------------------------------------------------ |
| `pds_build_info` | the version, as a label |
| `pds_http_requests_total{route,status}` | requests by method and status |
| `pds_http_request_duration_seconds{route}` | a histogram of latency by method |
| `pds_firehose_subscribers` | open firehose connections |
| `pds_audit_entries` | entries in the audit log |
| `pds_audit_unsigned_entries` | entries not yet under a signed checkpoint |
| `pds_audit_checkpoint_age_seconds` | time since the last checkpoint |
| `pds_notice_outbox_depth` | mail waiting to go out, in the `linkjar` profile |
A `route` label is a method the server handles, a path it knows, `proxied` or `other`, so a client cannot make up a label.
## What to alert on
| Signal | Means |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `pds_http_requests_total{status=~"5.."}` rising | the server fails requests; read the logs |
| the 99th percentile of `pds_http_request_duration_seconds` | the host is short of CPU or disk, or a client is heavy |
| `pds_audit_unsigned_entries` above 0 for more than ten minutes | checkpoints stopped; the key is missing or the clock is off |
| `pds_notice_outbox_depth` growing | SMTP fails |
| `pds_firehose_subscribers` at 0 for long | the relay is not connected; see [the first account](https://pds.linkjar.io/start/first-account/#when-posts-reach-other-people) |
## Rate limits
The reference server’s limits run by default: by client address for requests overall and for sign-ups and sign-ins, and by account for writes. Every answer carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`; a refused request is a 429 with `Retry-After`. The server uses the connection address and forwarding from private proxy hops. The supplied Caddy setups forward the client address. Keep the upstream HTTP listener private so public clients cannot bypass the proxy.
# Update
> Update a pinned native binary, NixOS package, or container image, and understand rollback limits.
[Source](https://pds.linkjar.io/operate/update/)
An update replaces the executable and restarts the service on the existing data. Record the current build, keep its configuration and secrets, and take a tested [backup](https://pds.linkjar.io/operate/backup/) first. Build or download the replacement before stopping the server. Review changes between the two source commits.
This release adds a credential recovery table to the account database and an index to actor databases on writable open. The first index build takes a SQLite write lock and extra disk space. Allow for that work in your maintenance window.
## Native binary
[Download and verify](https://pds.linkjar.io/start/builds/#download-a-portable-linux-build) a new archive, or build the selected source revision. Keep the old executable in its versioned `/opt/linkjar-pds/` directory. Install the new executable under a new commit directory before changing the symlink.
Stop the service, then select the new executable. Set `PDS_REV` to the full reviewed commit whose binary you installed:
```bash
sudo systemctl stop linkjar-pds
sudo ln -sfn "/opt/linkjar-pds/$PDS_REV/linkjar-pds" /usr/local/bin/linkjar-pds
```
Use the [native command helper](https://pds.linkjar.io/operate/cli/#native-services), with `PDS_BIN=/usr/local/bin/linkjar-pds`, to check configuration and data before startup:
```bash
pds check-config
pds verify
sudo systemctl start linkjar-pds
```
A failed check leaves the server stopped. Fix the problem before reopening it. A Cargo build needs its compatible host libraries. A normal Nix package needs its store closure and a retained garbage-collection root. The static Linux binary needs the host’s CA bundle. Keep the build type consistent unless you have tested a change, including throughput on your workload.
## NixOS
Change the `linkjar-pds` input URL in your host flake to the full reviewed commit. Update only that input in the host’s lockfile:
```bash
nix flake update linkjar-pds
```
Review the host flake and lockfile diff, then build the host configuration with your usual `nixos-rebuild build --flake ...` command. Take the backup and activate the reviewed configuration with `nixos-rebuild switch --flake ...`. Use your actual host flake target in place of `...`.
The module validates configuration before starting the service. Keep the runtime environment file available through activation. NixOS generations record the package; they do not snapshot the PDS data or runtime secrets. See the [Nix input update reference](https://nix.dev/manual/nix/2.28/command-ref/new-cli/nix3-flake-update.html) for updating a single input.
## Docker Compose
Resolve the image tag to its immutable digest:
```bash
docker buildx imagetools inspect ghcr.io/linkjar/pds-server:main --format '{{.Manifest.Digest}}'
```
Or [build it yourself](https://pds.linkjar.io/start/install/#choose-the-image). Set `PDS_IMAGE` in `.env` to the new digest, then:
```bash
docker compose pull
docker compose up -d
```
Compose replaces the server container and leaves Caddy running. Pin a digest; `:main` moves with every merge and cannot identify an exact rollback build.
## Verify the update
For NixOS or a native systemd service:
```bash
sudo systemctl status linkjar-pds
sudo journalctl -u linkjar-pds --since '2 minutes ago' --no-pager
```
For Docker:
```bash
docker compose ps
docker compose logs --since 2m pds
```
From outside the host, check HTTPS and the server metadata as in [setup verification](https://pds.linkjar.io/start/verify/). Also test sign-in and a representative read:
```bash
curl --fail https://pds.example.com/xrpc/_health
```
On `SIGTERM`, the server stops taking connections, finishes writes in flight, closes the firehose so the relay can resume at its cursor, and exits. The supplied native services allow 30 seconds; Compose allows 60 seconds.
## Roll back
For a native binary, stop the service, point `/usr/local/bin/linkjar-pds` back to the retained executable, check it, and start. For NixOS, activate the previous reviewed host configuration or generation. For Docker, restore the old digest in `.env` and run `docker compose up -d`.
Check schema compatibility for the selected older build before serving data. An executable rollback does not restore the databases. The additive recovery table and actor index remain readable by older servers, but authentication protection can differ.
The reference server and older Candidate builds do not enforce credential epochs or the member host’s live session check. They can accept revoked, unexpired legacy tokens after a password recovery. If recovery must remain effective, rotate the token-signing secrets and keys and require sign-in again before serving with such a build. Keep the account database and its recovery table in every [backup](https://pds.linkjar.io/operate/backup/).
# How it fits together
> The parts of the server, what it writes to disk, and the two ways to deploy it, in three diagrams.
[Source](https://pds.linkjar.io/reference/architecture/)
The server is one process with three listeners: the public one that Caddy forwards to, and two private ones for metrics and for the console. It keeps everything in one data directory.
## Who talks to it

Apps sign in and read and write over XRPC. The relay subscribes to the firehose. The server registers DIDs with the PLC directory and forwards app requests to the AppView.
Apps, the Bluesky app among them, sign in with OAuth or a password and read and write records over XRPC. The relay at `bsky.network` subscribes to the firehose and feeds the AppView, which serves timelines and notifications back to the apps through the server. The PLC directory holds the DID documents. The two sidecars are optional.
## What it writes

The data directory has the reference server's layout: shared databases, one store and one signing key per account, and the blobs.
Each account’s repository is a SQLite file of its own, with its signing key beside it. The shared databases hold the accounts and sessions, the event log of the firehose, cached DID documents, the audit log, and the server’s operator state. Blobs are files, or objects in a bucket. [Back up and restore](https://pds.linkjar.io/operate/backup/) says which to keep.
## One host, or an entryway

A single node is the usual deployment. An entryway splits accounts from repositories to grow past one host.
A single node serves everything from one data directory, and this guide is written for it. An [entryway](https://pds.linkjar.io/scale/entryway/) keeps the accounts and the OAuth server in front of a member host that keeps the repositories; today one member host is supported.
## Further reading
* [docs/architecture](https://github.com/linkjar/pds/blob/main/docs/architecture/README.md): one diagram per part of the server, including the write path, the firehose, OAuth and the extension model.
* [docs/SPEC.md](https://github.com/linkjar/pds/blob/main/docs/SPEC.md): the specification, which says what the server must do and where it differs from the reference server on purpose.
# Troubleshooting
> What goes wrong most, what it looks like, and what fixes it.
[Source](https://pds.linkjar.io/reference/troubleshooting/)
| You see | Cause | Fix |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `check-config` names a variable | The value is missing or malformed. | Fix the setting in the runtime environment file and run the check again. The message says what shape it expects. |
| `docker-compose: command not found`, or an error about the Compose file’s version | Compose version 1. | Install the Compose plugin and use `docker compose`, with a space. |
| The server exits at start and the log says another server holds the lock | Another process still runs, or the lock file is left from a copy. | Check `systemctl status linkjar-pds` or `docker compose ps`; stop the process. A stale `linkjar-pds.lock` in a copied directory can be removed when no server runs there. |
| `curl` to the server fails with a certificate error on the first request | Caddy fetches the certificate on the first connection, which takes a few seconds. | Try again. If it keeps failing, DNS does not point at the host, or port 80 or 443 is closed. |
| A handle’s name gets no certificate | The wildcard record is missing, or the handle is not an active account. | Check `dig +short anything.pds.example.com`, and the `/tls-check` route in [the checks](https://pds.linkjar.io/start/verify/#the-certificate-guard). |
| The Bluesky app signs in but cannot load settings, and the log shows `getPreferences` failing | `PDS_BSKY_APP_VIEW_URL` and `PDS_BSKY_APP_VIEW_DID` are unset. | Set both, as in the example file, and restart. |
| Sign-up fails with an invite code error | `PDS_INVITE_REQUIRED` is on and the code is wrong or used up. | Create a code with the [admin API](https://pds.linkjar.io/operate/accounts/#invite-codes). |
| Sign-up fails and the log mentions the rotation key | `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` is unset. | Generate one as in [the install](https://pds.linkjar.io/start/install/) and restart. Without it the server creates no account. |
| Posts do not appear for people on other servers | The relay has not crawled the host yet, or cannot reach it. | Wait for the first write after a start, then check `getHostStatus` as in [the first account](https://pds.linkjar.io/start/first-account/#when-posts-reach-other-people). The firehose must be reachable at `wss://pds.example.com`. |
| Password reset mail never arrives | SMTP is not set, or the URL is wrong. | [Email](https://pds.linkjar.io/configure/email/). A wrong URL shows in the log of the request. |
| The firehose subscriber count stays at 0 | The relay is not connected. | Same as the posts above. A proxy in front of DNS that drops long WebSockets is a common cause. |
| `verify` prints differences after a restore | The backup may be inconsistent, or blobs may be missing. | Restore a tested cold backup or consistent snapshot, including its WAL and external storage. Copying live files separately is insufficient. |
| A second host started on a copy of the directory | Two servers served one set of accounts. | Stop one at once. The relay and the apps saw two histories; the one that keeps running is the truth, and the other’s writes since the copy are lost. |
For native services, read `sudo journalctl -u linkjar-pds`; for Compose, read `docker compose logs pds`. Set `LOG_LEVEL=debug` and restart for more detail. A foreground native binary needs its settings exported; a nearby `.env` file is not loaded automatically. Check CA certificates if outbound HTTPS fails.
Open an issue at [github.com/linkjar/pds](https://github.com/linkjar/pds/issues) with the relevant log lines, installation method, and source commit. Review logs and configuration excerpts for private information before sharing them.
# Entryway and member host
> Split one server into an entryway that keeps the accounts and a member host that keeps the repositories, without changing a DID document.
[Source](https://pds.linkjar.io/scale/entryway/)
An entryway is the way to grow past one host. It keeps the accounts, the sessions, the OAuth server and the PLC rotation key, and routes everything else to a member host, which keeps the repositories, the blobs, the signing keys and the firehose. The old server becomes the member host and keeps its address, so no DID document changes.
Today an entryway serves one member host. Rehearse the split on a copy first, and tell the people on the server before the day: every OAuth client must sign in again, because the member host is no longer an authorization server.
## What to know first
* `PDS_ENTRYWAY_URL` of the member host is the public address of the entryway. OAuth clients read it, and tokens name it as their issuer.
* Sessions with a password or an app password carry on: the client refreshes once and gets tokens of the entryway.
* After local token checks, the member checks current legacy or OAuth session state at the entryway. Results are not cached. Password recovery takes effect at the next authenticated member request. This adds one round trip, capped at five seconds or `PDS_PROXY_HEADERS_TIMEOUT` if shorter. If the entryway cannot answer, the member refuses the request with 503 `UpstreamFailure`.
* `PDS_ENTRYWAY_ADMIN_TOKEN` must contain the entryway’s admin password. The member uses it for the private `/oauth/introspect` check and admin forwarding. Keep it in the member’s secret store.
* The entryway passes uploads, exports and the firehose through to the member host as streams. Only the member host asks the relay to crawl it.
* A member host answers no handle. `/.well-known/atproto-did` on the handle names must reach the entryway, so the wildcard DNS and the Caddyfile move to it.
## Prepare
1. Choose the entryway’s name, such as `entryway.example.com`, and point it at the new host.
2. Create the key of the tokens, 32 random bytes as 64 hexadecimal digits:
```bash
openssl rand -hex 32
```
It goes into the entryway’s secrets. The member host needs the public key, which the entryway logs at start as `jwt_verify_key_k256_public_key_hex`, with its DID.
3. Note the `did:key` of the old server’s PLC rotation key. The entryway takes the private key; the member host gets the `did:key`.
## Split
1. Stop the old server.
2. Copy the complete `account.sqlite`, including `credential_epoch`, from its data directory to the entryway’s.
3. Configure the entryway with the old server’s variables, and:
| Variable | Value |
| --------------------------------------------------- | --------------------------------------------------------- |
| `PDS_HOSTNAME` | the entryway’s name |
| `PDS_JWT_SECRET` | the old server’s; it takes the refresh tokens from before |
| `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | the old server’s |
| `PDS_MEMBER_URL` | the old server’s public address |
| `PDS_MEMBER_INTERNAL_URL` | where the entryway reaches it |
| `PDS_MEMBER_ADMIN_PASSWORD` | the old server’s admin password |
| `PDS_ENTRYWAY_JWT_SIGNING_KEY_K256_PRIVATE_KEY_HEX` | the new key |
4. Configure the old server as the member host. Keep its variables, and:
| Variable | Value |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `PDS_ENTRYWAY_URL` | the entryway’s address |
| `PDS_ENTRYWAY_DID` | `did:web:` and the entryway’s name |
| `PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX` | the public key |
| `PDS_ENTRYWAY_PLC_ROTATION_KEY` | the `did:key` of the rotation key |
| `PDS_ENTRYWAY_ADMIN_TOKEN` | the entryway’s `PDS_ADMIN_PASSWORD` |
| `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | remove it |
| `PDS_JWT_SECRET` | keep it; the member host answers `ExpiredToken` to a token from before, and the client refreshes |
5. Send `/.well-known/atproto-did` of the handle names to the entryway.
6. Start the entryway, then the member host.
## Check
1. Sign in at the member host’s address with a password. The entryway answers, and the session writes a record.
2. Refresh a session from before the split.
3. Create an account at the entryway. Its DID document names the member host.
4. Change a handle. Both servers show it.
5. Recover a test account’s password. Its previous legacy and OAuth tokens must fail on the member host; a fresh sign-in must work.
## Reconcile
A crash during a sign-up can leave a repository on the member host with no account at the entryway. At the entryway, use `pds reconcile` with the [native CLI helper](https://pds.linkjar.io/operate/cli/#native-services), or for Compose:
```bash
docker compose exec pds linkjar-pds reconcile
```
It lists each repository without an account and each account without a repository, and exits 1 when it finds one. Run it again with `--remove-orphans` to remove the repositories without an account; one with a commit in the last ten minutes stays, because it may be a sign-up in progress.
## Back to one server
Stop both. Remove the `PDS_ENTRYWAY_*` variables from the old server and give it its rotation key back. Copy `account.sqlite` from the entryway back: it has the accounts, sessions and recovery epochs since the split. A repository the member host created since then is in its directory already. Start the old server; clients refresh once more.
The [runbook](https://github.com/linkjar/pds/blob/main/docs/runbooks/entryway.md) in the repository has the same procedure with the specification’s references.
# Postgres for the shared tier
> Move the accounts, the event log, the DID cache and the audit log from SQLite files to Postgres, and back.
[Source](https://pds.linkjar.io/scale/postgres/)
Four of the server’s databases are shared by every account: the accounts, the event log, the DID cache and the audit log. They can live in Postgres instead of SQLite files. The repositories and the blobs stay in the data directory either way.
Most hosts never need this. Postgres is for an operator whose backups and replication are already Postgres, or who plans an [entryway](https://pds.linkjar.io/scale/entryway/) later.
## What to know first
* **One server.** The tier serves one `linkjar-pds` process. A second one on the same schemas exits 2 at start.
* **No TLS.** The server reaches Postgres without TLS. Run the two on one host or one private network. The URL takes no option but `sslmode=disable`.
* **Sign-in** with `scram-sha-256` or a clear-text password. `md5` is not supported.
* **Backups change.** A restore must bring back Postgres and the data directory from the same moment, because the repositories and the event log refer to each other. Preserve the account schema’s `credential_epoch` table so password recovery continues to reject old tokens. Storage migration copies this table in both directions.
## Command conventions
The examples below use Compose. For NixOS or a native systemd service, use `sudo systemctl stop linkjar-pds` and `sudo systemctl start linkjar-pds`. Replace `docker compose run --rm pds linkjar-pds ` with `pds ` through the [native CLI helper](https://pds.linkjar.io/operate/cli/#native-services). Update the native runtime file and use the database’s reachable host address; the Compose name `db` does not resolve on a plain host. Keep the server stopped during migration.
## Move to Postgres
1. Create a database and a role that owns it. The server creates four schemas in it: `pds_account`, `pds_sequencer`, `pds_did_cache` and `pds_audit`.
2. Stop the server.
```bash
docker compose stop pds
```
3. Add the URL to `pds.env`. Set `PDS_POSTGRES_SCHEMA_PREFIX` when `pds` is taken. Remove `PDS_ACCOUNT_DB_LOCATION`, `PDS_SEQUENCER_DB_LOCATION` and `PDS_DID_CACHE_DB_LOCATION` if they are set, so that the copy finds the files at their default places.
```ini
PDS_POSTGRES_URL=postgres://pds:password@db:5432/pds
```
4. Copy.
```bash
docker compose run --rm pds linkjar-pds migrate-storage --to postgres
```
It prints one line per table and ends with a line that says the row counts, the head of the event log and the last checkpoint are the same on both sides. An exit code of 2 means nothing was switched: read the message.
5. Check the directory against the new tier, then start.
```bash
docker compose run --rm pds linkjar-pds verify
```
```bash
docker compose up -d
```
6. Keep the SQLite files until the first backup of Postgres exists. Then move them out of the data directory: a later copy back needs the places empty.
## Back to SQLite
1. Stop the server.
2. Move `account.sqlite`, `sequencer.sqlite`, `did_cache.sqlite` and `audit.sqlite` out of the data directory, with their `-wal` and `-shm` files. The copy refuses a target that exists.
3. Copy, with `PDS_POSTGRES_URL` still set:
```bash
docker compose run --rm pds linkjar-pds migrate-storage --to sqlite
```
4. Remove `PDS_POSTGRES_URL` from `pds.env`, run `verify`, and start.
## When the copy fails
The copy writes to the target only, so a copy that fails leaves the source as it was. Remove what the target got, the four schemas in Postgres or the four files on disk, and run the copy again.
# Console and MCP server
> Optional console and MCP sidecars, with Compose deployment examples and native build scope.
[Source](https://pds.linkjar.io/scale/sidecars/)
For a first setup, use the dedicated [MCP guide](https://pds.linkjar.io/connect/mcp/) or [operations console guide](https://pds.linkjar.io/connect/console/). This page keeps the Compose examples and existing links together. The [binary and port map](https://pds.linkjar.io/reference/binaries/) explains the native equivalents.
Both sidecars talk to the server over its APIs. Neither holds a database connection, a signing key or a secret of the server, so each can be added and removed without touching the data directory, and every action they take is in the [audit log](https://pds.linkjar.io/operate/audit-log/).
The examples on this page use Docker Compose. The native PDS archives and Nix packages include only `linkjar-pds`, not these sidecars. A native PDS can use separately built sidecars through the same APIs. Replace Compose DNS names with reachable host addresses and keep operations listeners private. Native listeners on the same host should use loopback, not the container-only `0.0.0.0` examples below.
## The operations console
A page with the live numbers of the server and the firehose subscribers, the accounts and the sessions of each, the audit log, the blocked email domains and the operator roles. It takes an account down and lifts the takedown, ends an account’s sessions, disconnects a subscriber, blocks an email domain, signs a checkpoint, and removes expired sessions. Each form has a field for the reason, which goes into the audit entry.
An operator signs in with their own account on the server, through OAuth, and the account needs a role. The console is a loopback client: reach it through an SSH tunnel, never under a public name.
### Run it
On the server’s side, in `pds.env`:
```dotenv
PDS_OPS_ADDRESS=0.0.0.0:2584
```
In `compose.yml`, a service beside `pds`:
```yaml
console:
image: ghcr.io/linkjar/pds-console@sha256:…
restart: unless-stopped
environment:
CONSOLE_ADDRESS: 0.0.0.0:2585
CONSOLE_PUBLIC_URL: http://127.0.0.1:2585
CONSOLE_PDS_PUBLIC_URL: https://pds.example.com
CONSOLE_PDS_INTERNAL_URL: http://pds:3000
CONSOLE_OPS_URL: http://pds:2584
ports:
- "127.0.0.1:2585:2585"
```
Start it and read its client id from its first log lines:
```bash
docker compose up -d console && docker compose logs console
```
Put the id into `pds.env` as `PDS_OPS_CLIENT_IDS` and restart the server. The ops listener takes a token only from a client on that list.
### Grant a role
Roles are `operator`, which takes every action but a role grant, and `moderator`, which reads, changes the status of a subject, ends sessions and disables invites. Only the admin password grants a role. Publish the ops listener on the host’s loopback, beside the console’s port:
```yaml
ports:
- "127.0.0.1:2584:2584"
```
Then, with `PDS_ADMIN_PASSWORD` in the environment and a reason, which every action on the ops listener requires:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'X-Ops-Reason: first operator' -H 'content-type: application/json' -d '{"did": "did:plc:…", "role": "operator"}' http://127.0.0.1:2584/xrpc/internal.ops.grantRole
```
### Open it
From your workstation, a tunnel to the host:
```bash
ssh -L 2585:127.0.0.1:2585 operator@pds.example.com
```
Open `http://127.0.0.1:2585`, and sign in with the account that holds the role. A restart of the console signs every operator out: it keeps the sessions in memory.
## The MCP server
An MCP server that AI clients connect to with OAuth, in order to read and write an account’s records with the account’s consent. It is a public service under a name of its own, such as `mcp.example.com`, behind Caddy. Toward the PDS it is an OAuth client with a key of its own; its own tokens never reach the PDS, and each write names the AI client in the audit entry.
Its configuration is `MCP_ADDRESS`, `MCP_PUBLIC_URL`, `MCP_PDS_PUBLIC_URL`, `MCP_PDS_INTERNAL_URL`, `MCP_CLIENT_KEY_P256_PRIVATE_KEY_HEX` and `MCP_WRITE_COLLECTIONS`, the collections an AI client may ask to write. Its client id is `MCP_PUBLIC_URL` followed by `/oauth-client-metadata.json`, and it logs it at start. On the server’s side, `PDS_MCP_CLIENT_IDS` names it, and `PDS_OAUTH_KNOWN_CLIENTS_FILE` can hold its client metadata so that the server fetches nothing. Sessions live in the process’s memory, so one instance runs and a restart ends every session.
The design and the state of both sidecars are in [docs/sidecars.md](https://github.com/linkjar/pds/blob/main/docs/sidecars.md) in the repository.