Multi-user install
You don't choose this up front. When someone maps to a Linux user other than your own, ./install.sh and
cloudflare-tmux add explain that the app must run as root to start a shell as that user, ask once, and switch.
This page describes what the switch does.
Use it when several people share a machine and each should get their own Linux user: their own files,
permissions and tmux sessions. Each Linux user must already exist and have a login shell. Create one with
sudo adduser alice.
To ask for it explicitly, for example in a script:
./install.sh --multi-user \
--host term.example.com \
--identities alice@example.com:alice,bob@example.com:bob
How it works#
- The app runs as root, as the system service
cloudflare-tmux.service, so it can start processes as other users. - For each request it checks the login, maps the email to a Linux user through
IDENTITIES, and starts tmux as that user withsetpriv. Each person gets their own tmux server and can't reach anyone else's sessions. - It refuses to map
root, any account with UID 0, and any account whose shell isnologinorfalse. - The tunnel stays a user service of the account that ran the installer.
Root-owned code#
A root service must not run code that a normal user can edit. So scripts/install-system.sh:
- copies
server.js,public/,node_modules/and thenodebinary to/opt/cloudflare-tmux, owned by root and writable by nobody else; - copies
~/.config/cloudflare-tmux/envto/etc/cloudflare-tmux/env, directory700and file600, droppingAUTH_DISABLED; - installs
/etc/systemd/system/cloudflare-tmux.serviceand disables the single-user app service, so they don't both claim port 7681.
After you change the config or the code#
Editing the checkout or the config file doesn't change what's running. Run:
scripts/cloudflare.sh term.example.com # only if IDENTITIES changed; asks for an API token
sudo NODE_BIN="$(command -v node)" scripts/install-system.sh # always; no token needed
NODE_BIN matters if you use nvm: sudo doesn't see your nvm node, so pass it explicitly.
Add or remove a person#
Create the Linux user first, then use the same command as in the single-user install. It detects the
multi-user install and re-runs install-system.sh for you, which asks for sudo.
sudo adduser carol
cloudflare-tmux add carol@example.com carol
cloudflare-tmux remove carol@example.com
See Cloudflare login for the Cloudflare side: inviting them as a member and the API token.
Switching from the single-user install#
You don't have to decide up front. When you add someone with a Linux user other than your own,
cloudflare-tmux add offers to switch. ./install.sh does the same when IDENTITIES names other users.
Your sessions and config stay as they are. Only the app service moves from your user to root.