---
title: "Deploy PrivateBin | (Just Updated) Encrypted Pastebin, Only You Can Create Pastes, Data Survives Redeploys"
description: "PrivateBin encrypted pastebin, paste creation needs a key, data kept"
category: "Other"
url: https://railway.com/deploy/privatebin-or-just-updated-encrypted-pas
---

# Deploy PrivateBin | (Just Updated) Encrypted Pastebin, Only You Can Create Pastes, Data Survives Redeploys

PrivateBin encrypted pastebin, paste creation needs a key, data kept

**[Deploy PrivateBin | (Just Updated) Encrypted Pastebin, Only You Can Create Pastes, Data Survives Redeploys on Railway](https://railway.com/template/privatebin-or-just-updated-encrypted-pas)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/privatebin-or-just-updated-encrypted-pas/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Other

## Template content

### privatebin

- **Image:** ghcr.io/bon5co/privatebin-railway:2.1.1@sha256:5268b19bf4a5dd6a19c22d4b42561a01b80c9e85c00a01462d595aa3ed869817
- **Health check:** /
- **Public domain:** Yes

## Documentation

# Deploy and Host PrivateBin on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the write key is generated, pastes sit on a volume, and nobody without the key can create a paste. PrivateBin is the open-source zero-knowledge pastebin: the browser encrypts a paste with a key that stays in the share link, so the server only ever stores ciphertext and cannot read it.

## About Hosting PrivateBin

This template runs one service, **privatebin** (the upstream nginx and PHP-FPM image, with a volume at `/srv/data` holding the stored pastes), so pastes survive redeploys until they expire.

**Upstream is open to everyone, this template is not.** Stock PrivateBin lets any visitor create pastes, so a public instance becomes free hosting for whoever finds the URL. The wrapper puts HTTP basic auth on every request that is not GET or HEAD, using the user `writer` and the generated `PRIVATEBIN_PASSWORD`. Reading stays public, so a share link opens for anyone who has it. The container refuses to start if the password is empty or shorter than 12 characters. The per-IP post limiter is switched off, because every request reaches the app from a rotating Railway edge address and only authenticated writers can post anyway.

**Using it.** Create a paste with `curl` as in the snippet below, or open `https://YOUR_DOMAIN` in a browser: the page loads for anyone, and creating a paste asks for the `writer` login. Upstream is PrivateBin 2.1.1.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `privatebin` service)
- Private URL: `http://privatebin.railway.internal:8080`
- Credentials: the variable `PRIVATEBIN_PASSWORD` on the `privatebin` service; the user name is fixed to `writer` (not a template variable)
- Auth: HTTP basic auth (`curl -u writer:$PRIVATEBIN_PASSWORD`) on every `POST`, `PUT`, `PATCH` and `DELETE`. `GET` and `HEAD` need no credential, so a share link opens for anyone. A wrong password or none answers `401`. PrivateBin has no user accounts, so there is no sign-up.
- Health: `GET /` returns 200

```bash
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, PRIVATEBIN_PASSWORD (variables of the privatebin service; the user name is writer); also curl, sed. Creates and deletes one throwaway paste.
R="https://$RAILWAY_PUBLIC_DOMAIN"; J="Content-Type: application/json"; X="X-Requested-With: JSONHttpRequest"
# a structurally valid, already-encrypted paste body (PrivateBin only stores ciphertext, so any well-formed blob is accepted)
BODY='{"v":2,"adata":[["AAAAAAAAAAAAAAAAAAAAAA==","AAAAAAAAAAA=",100000,256,128,"aes","gcm","none"],"plaintext",0,0],"meta":{"expire":"5min"},"ct":"dGVzdGNpcGhlcnRleHRkYXRhMTIzNDU2Nzg5MDEyMw=="}'
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/"
# write with the key: create a paste, read it back without any credential, delete it with its delete token
OUT=$(curl -s -u "writer:$PRIVATEBIN_PASSWORD" -H "$X" -H "$J" -d "$BODY" "$R/")
ID=$(echo "$OUT" | sed -n 's/.*"id":"\([^"]*\)".*/\1/p'); DT=$(echo "$OUT" | sed -n 's/.*"deletetoken":"\([^"]*\)".*/\1/p')
if [ -n "$ID" ]; then echo "write paste: created"; else echo "write paste: FAILED"; fi
curl -s -H "$X" "$R/?pasteid=$ID" | grep -o '"status":0' | head -1 | sed 's/^/read back without key: /'
curl -s -G -H "$X" --data-urlencode "pasteid=$ID" --data-urlencode "deletetoken=$DT" "$R/" | grep -o '"status":0' | head -1 | sed 's/^/delete paste: /'
curl -s -H "$X" "$R/?pasteid=$ID" | grep -o '"status":1' | head -1 | sed 's/^/read after delete: /'
# refusals: wrong key, no key
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -u "writer:not-the-secret-0000" -H "$X" -H "$J" -d "$BODY" "$R/"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -H "$X" -H "$J" -d "$BODY" "$R/"
# signup: none - PrivateBin has no accounts; creating a paste is the only write path and it is the gated one above
```

Expected output against a fresh deploy (measured on a Railway deploy of this template):

```text
health: 200
write paste: created
read back without key: "status":0
delete paste: "status":0
read after delete: "status":1
write wrong key: 401
write without key: 401
```

The refusals are the contract: `write wrong key: 401` and `write without key: 401`. Reading the paste back without a credential succeeds on purpose, and `read after delete: "status":1` shows the delete token removed it.

## Why Deploy PrivateBin on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying PrivateBin on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Agent-ready** - no deployer fields, a contract block and one script that proves a paste can be written with the key, read back, deleted, and refused without it.
- **Only the key holder can write** - stock PrivateBin accepts pastes from anyone; here creation needs a generated password.
- **Share links stay public** - reading a paste needs no login, so you can hand a link to anyone.
- **Data survives redeploys** - stored pastes sit on a volume owned by the app user.
- **Pinned** - the upstream image is pinned by digest and the wrapper by tag and digest.

## Common Use Cases

- **Private pastebin for a team** - share logs, configs and secrets as encrypted pastes that expire or burn after reading.
- **Agent output sharing** - an agent posts a long result and returns a link a person can open.
- **Self-hosted alternative to public paste sites** - your data stays on a domain you control, and the server cannot read it.
- **Incident and support snippets** - one-time links for credentials or stack traces.

## Dependencies for PrivateBin Hosting

- The privatebin service with its volume, created by the template. A custom domain is optional.

### Deployment Dependencies

- [PrivateBin repository](https://github.com/PrivateBin/PrivateBin)
- [PrivateBin documentation](https://github.com/PrivateBin/PrivateBin/wiki)
- [Wrapper image source](https://github.com/bon5co/privatebin-railway)


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/privatebin-or-just-updated-encrypted-pas
