Home / Docs / DCA Hardened Identity Provider — for Keycloak™ / Configuration
Keycloak 26.8 in production mode, console on loopback, and an administrator plus realm keys created on each VM's first boot — none ship in the image.
On this page: Installed version · First-boot credentials · Log in · Replace the bootstrap administrator · Network access · Database and single-node design · Data and logs · Upgrades · Backup and restore
cache=local), and nothing but SSH listens beyond loopback. Expose Keycloak only over HTTPS — see Network access.Keycloak 26.8.0 — the upstream server distribution, verified when the image was built three ways (a pinned sha256, Maven Central's .sha256 for the same artifact, and the release's GPG signature from the Keycloak Bot key), unpacked in /opt/keycloak and owned by the keycloak user. It runs in production mode (kc.sh start --optimized) on Ubuntu's OpenJDK 21 (openjdk-21-jre-headless) under keycloak.service; the build options were baked once with kc.sh build. Base OS: Ubuntu 24.04 LTS. Image built 2026-10-07; every build is gated on zero fixable HIGH or CRITICAL vulnerability findings.
sudo -u keycloak /opt/keycloak/bin/kc.sh --versionNo administrator, realm or realm key ships in the image. On this VM's first boot, keycloak-firstboot.service generates a bootstrap administrator before Keycloak first starts; Keycloak then creates the master realm — with its own signing keys — and that administrator. keycloak-verify-firstboot.service proves the administrator gets a token from the running server and a wrong password is refused, then deletes the bootstrap environment file.
| File | Owner / mode | Contents |
|---|---|---|
/root/keycloak-admin-credentials.txt | root:root 0600 | KEYCLOAK_ADMIN_USER=admin and KEYCLOAK_ADMIN_PASSWORD=… (32 characters, unique to this VM) |
/etc/keycloak/bootstrap-admin.env | root 0600 | KC_BOOTSTRAP_ADMIN_USERNAME / KC_BOOTSTRAP_ADMIN_PASSWORD for the very first start only — deleted once the administrator is proven |
/opt/keycloak/data/h2/ | keycloak | The realm database Keycloak creates on its first start (master realm keys, users) |
gcloud compute ssh INSTANCE_NAME --zone ZONE --tunnel-through-iap. The deployment package enables OS Login, so IAM decides who can SSH in; reading the credential files needs sudo, which OS Login grants to principals with the OS Admin Login role (roles/compute.osAdminLogin). IAP TCP forwarding needs a firewall rule that allows 35.235.240.0/20 to tcp:22 on the VM's network — the deployment package does not create one.gcloud compute ssh INSTANCE_NAME --zone ZONE --tunnel-through-iap -- -L 8080:127.0.0.1:8080
sudo cat /root/keycloak-admin-credentials.txtmaster realm as admin. Plain HTTP is fine here because the tunnel ends on the VM's loopback; Keycloak refuses admin sign-in over plain HTTP from non-local addresses (the master realm requires SSL for external requests).Keycloak treats an administrator created this way as a temporary (bootstrap) admin, and the credential file says the same: sign in, create a permanent administrator, then delete or re-password admin.
master realm open Users → Add user, give the new administrator a username, and create it.master realm role admin.admin user — or give it a new password you keep elsewhere.| Port | Bound to | Deployment package |
|---|---|---|
| 8080 (HTTP: console, realms, API) | 127.0.0.1 — http-host=127.0.0.1, http-port=8080 | none — use the IAP tunnel |
9000 (management: /health/ready) | inherits http-host — 127.0.0.1 | none |
| 8443 (HTTPS) | not listening until you configure a certificate | tcp:8443 toggle, off by default |
| 22 (SSH) | all interfaces | no rule — your VPC's own firewall rules apply |
keycloak user can read them:sudo install -d -o root -g keycloak -m 0750 /etc/keycloak/tls
sudo install -o root -g keycloak -m 0640 fullchain.pem /etc/keycloak/tls/tls.crt
sudo install -o root -g keycloak -m 0640 privkey.pem /etc/keycloak/tls/tls.key/opt/keycloak/conf/keycloak.conf with sudo. These are runtime options, so no kc.sh build is needed. Change the existing http-enabled and http-host lines rather than adding second copies:https-certificate-file=/etc/keycloak/tls/tls.crt
https-certificate-key-file=/etc/keycloak/tls/tls.key
https-port=8443
hostname=https://idp.example.com:8443
http-enabled=false
http-host=0.0.0.0curl -fsSk https://127.0.0.1:9000/health/ready:sudo systemctl restart keycloak
sudo journalctl -u keycloak -n 40 | grep -i listeningDEPLOYMENT-tcp-8443, allowing tcp:8443 from those ranges to VMs tagged DEPLOYMENT-deployment (DEPLOYMENT is your deployment name; the VM is DEPLOYMENT-vm). Use the narrowest ranges that work — 0.0.0.0/0, which the field shows only as a format example, would publish the port through the VM's external IP. Already deployed without the toggle? Create the same rule yourself:gcloud compute firewall-rules create DEPLOYMENT-tcp-8443 \
--network NETWORK --direction INGRESS --allow tcp:8443 \
--source-ranges 10.10.0.0/24 --target-tags DEPLOYMENT-deploymenthttp-host sets the address of every Keycloak listener — HTTPS and the management interface on 9000 as well — so with 0.0.0.0 the health endpoints also answer on the VM's internal IP. The deployment package opens only 8443.
Terminate TLS in front of Keycloak and tell Keycloak about the proxy with proxy-headers=xforwarded (or forwarded) and hostname=https://idp.example.com. The proxy must reach Keycloak's HTTP port, so set http-host to an address it can reach and allow that port from the proxy's source ranges only — the deployment package's toggle covers 8443, not 8080.
default network that still has its pre-created default-allow-internal rule (all ports from 10.128.0.0/9), every VM in that network can connect as soon as the service listens on the internal IP — toggle or not. And the deployment package gives the VM an ephemeral external IP by default (its External IP field), so a rule open to 0.0.0.0/0 would put the service on the internet. Put authentication in place first, then open the narrowest range that works.The shipped keycloak.conf uses db=dev-file — Keycloak's embedded H2 file database, in /opt/keycloak/data/h2 — and cache=local, so this is a single node with no cluster traffic. Keycloak's own guidance for production is an external database. To move to PostgreSQL:
sudo systemctl stop keycloak
sudo -u keycloak /opt/keycloak/bin/kc.sh export --dir /opt/keycloak/data/exportkeycloak.conf set db=postgres plus db-url, db-username and db-password.db, cache, health and features are build options and the service starts with --optimized, so rebuild before starting:sudo -u keycloak /opt/keycloak/bin/kc.sh build
sudo -u keycloak /opt/keycloak/bin/kc.sh import --dir /opt/keycloak/data/export
sudo systemctl start keycloak| What | Where |
|---|---|
| Realm database | /opt/keycloak/data/h2/ (H2 file database, db=dev-file) |
| Logs | the systemd journal — journalctl -u keycloak -f (no log file is configured) |
| Configuration | /opt/keycloak/conf/keycloak.conf (keycloak, 0640) |
| Disk | The deployment package creates one boot disk (default 50 GB, balanced persistent disk) and no separate data disk, so the data above lives on the boot disk — size it for your data, or mount a persistent disk at the data path. |
kc.sh import while its service is stopped. The new VM creates its own bootstrap administrator on first boot; importing your master realm brings your own administrators across.apt nor unattended-upgrades (enabled, for Ubuntu's updates including OpenJDK 21) ever changes it. Back up /opt/keycloak/data, unpack the newer, verified distribution next to /opt/keycloak, copy conf/keycloak.conf and data/ across, run kc.sh build as keycloak, and switch over; Keycloak migrates its database on the new version's first start. Read Keycloak's upgrading guide first.Stop keycloak and copy /opt/keycloak/data (the H2 database), or snapshot the boot disk. kc.sh export (service stopped) also gives a portable JSON copy of realms and users that kc.sh import restores.
curl -fsS http://127.0.0.1:9000/health/ready → status UP — wire this into an uptime check or your monitoring agent.google-logging-enable=0, google-monitoring-enable=0), and the image pre-installs no monitoring agent. Install the Google Cloud Ops Agent if you want logs and metrics in Cloud Logging and Cloud Monitoring; nothing phones home by default.More: install · troubleshooting · security notes · support card. Questions: support@dcassociatesgroup.com — first response within 1 business day.
Keycloak™ names the open-source software this image packages. Derek Coleman & Associates Inc is not affiliated with or endorsed by the Keycloak project.