PTGBastion

Run your own server

A server for a unit

Set up a self-hosted server for an enterprise unit, with an account for each role.

Before you begin

A unit is an enterprise feature. Each device needs an enterprise licence in the app to use it. The licence is the same whether your unit is on your own server or on ours; see Before you start.

You'll need to decide:

  • a unit name, short and lowercase, such as phoenix;
  • your team names, also short and lowercase, such as raptor and viper. You can add teams later.

Unit and team names become part of the account names, and an account name can be at most 32 characters.

If we set your unit up for you, it shows as Self-hosted on its page in My units. Keep managing its teams, members and licences there. Device credentials and the unit's files aren't offered there, because they live on this server: the accounts below take their place.

Set up the server

Download and unzip the server kit. Run these from inside the bastion-server folder, with your own names and your server's address:

python3 bastionctl.py --root ./data init
python3 bastionctl.py --root ./data provision phoenix --teams raptor viper --host 192.168.1.50
docker compose up -d --force-recreate

provision does everything in one step:

  • creates the unit's folders;
  • creates an account for each role;
  • creates the server's identity keys, once, in hostkeys/;
  • writes a connection card for every account into setup-phoenix/.

You can run it again safely. It adds what's missing and never changes existing passwords or the identity keys.

The accounts

A self-hosted unit has one account for each role, not one for each device:

Account Who uses it What it can do
phoenix-gold The unit's gold admin Write the unit's gold copy, the unit share and every team's published set. Clean up members' shares. See and read every assistance report.
phoenix-raptor-lead The lead of team raptor Read gold. Write the unit share and their team's published set. Clean up their members' shares. Send reports, but not see them.
phoenix-raptor The members of team raptor Read gold and their team's published set. Write their own share folder. Send reports, but not see them.

Every member of a team uses the same members account.

Hand out the cards

setup-phoenix/ holds a file named card-<account>.txt for each account, and SETUP-README.txt with a summary of this setup.

Give each person the card for their role. A card contains a password: hand it over in person and don't send it in the clear.

To print a card again later:

python3 bastionctl.py --root ./data card --unit phoenix --host 192.168.1.50
python3 bastionctl.py --root ./data card --unit phoenix --team raptor --lead --host 192.168.1.50
python3 bastionctl.py --root ./data card --unit phoenix --team raptor --host 192.168.1.50

The first is the gold admin's card, the second a team lead's, the third the team members'.

Connect the devices

The gold admin's device goes first. The other devices can only join once the gold admin has published to gold at least once.

Everything below is under Settings, ENTERPRISE, Enterprise Options, except adding the server, which is on the Sync screen. To add the server, open Sync, then + Add Server, leave the protocol on SFTP, type in the card for that person's role, and change Port to the one on the card (2222 with the kit). On the first sync, check the key fingerprint against the card and choose Trust & Sync.

The gold admin's device

  1. Under LICENSE, choose Scan or Enter, give the licence code, and choose Activate. The unit's name comes from the licence; you don't type it.
  2. Under PROVISIONING PASSPHRASE, choose Set. This passphrase seals the unit's settings. Give it to the others yourself, separately from their connection cards.
  3. Under TEAMS, choose + Add grant and add Unit Admin. It is unit-wide and needs no team.
  4. Add the server with the gold admin's card, arm the Network Gate and sync.
  5. Publish to gold once, from the ENTERPRISE section of the Sync screen.

Every other device

  1. Under PROVISIONING PASSPHRASE, set the passphrase the gold admin gave you. These devices do not enter a licence.
  2. Add the server with the card for that person's role, arm the Network Gate and sync.
  3. When the app offers the unit's new settings, choose to apply them. The unit's configuration applies and the licence unlocks by itself.
  4. Under TEAMS, choose + Add grant and enter the team name and the role, Team Member or Team Admin. Team names are case-sensitive: type them exactly as the unit issued them.
  5. Under IDENTITY, type a Callsign and choose Save callsign. It can be changed at any time.

A device can hold more than one team and role. Each shows under TEAMS; tap the one to act as.

The role set in the app should match the account on the card. The server only allows what the account allows.

How the unit's storage is laid out

Everything for the unit is under data/units/phoenix/:

Folder What it is
gold/ The unit's gold copy. The gold admin publishes it; every device downloads it.
shared/_unit/ The unit share: a review area for team leads and the gold admin. Members never see it.
shared/raptor/_team/ Team raptor's published set. The lead writes it; the team downloads it.
shared/raptor/<device>/ One device's own share folder. There is one for each device.
reports/ Assistance reports uploaded by devices. Only the gold admin can see them.

Gold, each team's published set and each device's share folder also hold a tools/ folder: data that BASTION modules share, such as EXCHECK's code table. The app manages it, so leave it alone. The unit share has none.

Add content for the unit

Content usually arrives from the app: the gold admin and the team leads publish from their devices.

You can also copy files straight onto the server, into the folder for their kind under gold/ or under a team's _team/ folder, for example data/units/phoenix/gold/library/. Devices download them on their next sync. The next time the gold admin (or that team's lead) syncs, their device records the new files so they appear in the app's lists and can be recalled. A device that already downloaded a file before it was recorded keeps its copy and does not download it again.

If you copy files in as root, restart the server afterwards so the right accounts can read them:

docker compose up -d --force-recreate

Add a team later

python3 bastionctl.py --root ./data team add phoenix hawk
python3 bastionctl.py --root ./data accounts write --dir .
docker compose up -d --force-recreate

Then print the new team's two cards.

Next: What the server enforces.