Install the server
Build shellgraph-server, prepare the PostgreSQL database and the master key, then start the server behind TLS.
Before you start
- To build: Go 1.27, Node.js 24, pnpm 11, and Podman for the image.
- To run: one Linux machine (amd64 or arm64), or a container runtime.
- PostgreSQL 14 or later (tested with PostgreSQL 18). The server keeps all its data there.
- An LDAP directory or an OIDC identity provider for the login. The server has no local users.
Build
Clone the repository and go to it.
git clone https://git.rda.run/shellgraph/server.git cd serverBuild the binary. The UI is in the binary.
make buildThe result is
bin/shellgraph-serverforlinux/amd64. For arm64, usemake build ARCH=arm64.Optional: build the container image
shellgraph-server:<version>.make image
The binary is compiled for x86-64 v3 (AVX2, all CPUs since 2013). For an older CPU, use make build GOAMD64=v2.
Prepare the database
Make a user and a database for the server. Run these commands as a PostgreSQL superuser.
createuser --pwprompt shellgraph createdb --owner shellgraph shellgraphPut the connection URL in the environment variable
SHELLGRAPH_DATABASE_URLof the server.export SHELLGRAPH_DATABASE_URL='postgres://shellgraph@db.example.net:5432/shellgraph?sslmode=verify-full&sslrootcert=/etc/shellgraph/db-ca.pem' export PGPASSWORD='<password>'
The server makes the tables at the first start, and changes them after an upgrade. Many servers can use the same database, for example behind a load balancer.
Make the master key
The server encrypts the SSH private keys with a master key. Without the master key, the server cannot read the credentials.
Make a key.
shellgraph-server keygenKeep the key in a safe place.
Put the key in the environment variable
SHELLGRAPH_KEYof the server.
Configure the login
Configure LDAP, OIDC, or both, before the first start. If no login method is configured, the server does not start.
Start the server
Set the variables.
export SHELLGRAPH_KEY='<key>' export SHELLGRAPH_DATABASE_URL='postgres://shellgraph@db.example.net/shellgraph?sslmode=verify-full&sslrootcert=/etc/shellgraph/db-ca.pem' export PGPASSWORD='<password>' export SHELLGRAPH_ADMIN_GROUP=shellgraph-admins export SHELLGRAPH_OIDC_ISSUER=https://id.example.net export SHELLGRAPH_OIDC_CLIENT_ID='<client ID>' export SHELLGRAPH_OIDC_CLIENT_SECRET='<client secret>'Start the server.
shellgraph-server serve --listen :8080
If a variable is missing or not valid, the server prints the problem and stops. For all flags and variables, see Command line and Environment variables.
Run in a container
The image has the binary and the public CA certificates. It runs as the user 10001. It has no volume, because the data is in PostgreSQL. If the database server has a certificate from a private CA, mount the CA file and set sslrootcert in the URL. For Kubernetes, see Run in Kubernetes.
Put the variables in a file, one
NAME=valueon each line, for example/etc/shellgraph/env.Make the file readable only by root. It contains the master key, the database password and the login secrets.
chmod 600 /etc/shellgraph/envStart the container.
podman run -d --name shellgraph -p 8080:8080 --env-file /etc/shellgraph/env \ -v /etc/shellgraph/db-ca.pem:/etc/shellgraph/db-ca.pem:ro shellgraph-server:<version>
Use TLS
Use HTTPS between the collectors and the server. Do one of these:
- Start the server with
--tls-certand--tls-key. - Put a reverse proxy with TLS in front of the server. The proxy must send the header
X-Forwarded-Proto: https. SetSHELLGRAPH_PUBLIC_URLto the public URL, so that the OIDC callback and the map links are correct.
The collector refuses an http:// server URL, except for localhost and 127.0.0.1. Security gives the reason.
Do a health check
curl https://shellgraph.example.net/healthz
The server returns {"status":"ok"}.
Back up
Back up the database and the master key to different places.
Make a copy of the database with
pg_dump. You can do this while the server runs.pg_dump --format custom --file /backup/shellgraph.dump 'postgres://shellgraph@db.example.net/shellgraph'Keep the master key in a different place, for example a password manager.