Skip to content
Live $100 credit at signup, up to $300 total Offer ends December 31, 2026 Get started →

Keycloak

Keycloak is an open-source identity and access management platform. It provides single sign-on (SSO), user federation, social and identity-broker login, and fine-grained authorization through standard protocols such as OpenID Connect, OAuth 2.0, and SAML.

ComponentVersion
Keycloak26.6.4
PostgreSQL18
DockerLatest stable
Ubuntu24.04 LTS

Keycloak runs in production mode (start) with a PostgreSQL database, as a Docker Compose stack.

ResourceMinimumRecommended
vCPU24
RAM2 GB4 GB
Storage20 GB40 GB

You can optionally set these when deploying Keycloak from the marketplace. Leave a password field blank to have a secure random value generated automatically.

VariableDescription
KEYCLOAK_ADMINUsername for the initial admin account. Defaults to admin
KEYCLOAK_ADMIN_PASSWORDPassword for the initial admin account
KC_HOSTNAMEPublic hostname or IP Keycloak is served from. Defaults to the VM’s private IP
ssh ubuntu@<your-vm-ip>

On the first boot, a setup script generates the admin and database passwords, writes the environment file, and starts the stack with Docker Compose. This takes 1-2 minutes. Track progress:

journalctl -u keycloak-first-boot.service -f

The login message (MOTD) confirms when Keycloak is ready and prints the admin credentials.

The credentials are also written to a root-only file:

sudo cat /etc/keycloak/credentials.txt

Open a browser and navigate to:

http://<your-vm-ip>:8080

Sign in with the admin user and the generated password.

FieldValue
Usernameadmin
PasswordFrom /etc/keycloak/credentials.txt

Keycloak runs as a Docker Compose stack in /opt/keycloak.

# Check status
cd /opt/keycloak && docker compose ps
# Restart
cd /opt/keycloak && docker compose restart
# View logs
cd /opt/keycloak && docker compose logs -f

Environment configuration: /opt/keycloak/.env. PostgreSQL data is stored under /opt/keycloak/data/postgres and is not exposed outside the Docker network.

Port 8080 is open on the VM’s network interface. UFW is enabled and allows SSH (port 22) and Keycloak (port 8080). Keycloak serves plain HTTP on 8080.

For production use, front Keycloak with a reverse proxy (Caddy, nginx, or Traefik) that terminates TLS on port 443 and forwards to port 8080, and set KC_PROXY_HEADERS=xforwarded in /opt/keycloak/.env. Restrict direct access to port 8080:

sudo ufw delete allow 8080/tcp
sudo ufw allow from <trusted-ip> to any port 8080

Last updated: