kcadm.sh
Keycloak Admin CLI
TLDR
SYNOPSIS
kcadm.sh command [endpoint] [options]
DESCRIPTION
kcadm.sh is the Keycloak Admin CLI, shipped in the bin directory of the Keycloak server distribution (kcadm.bat on Windows). It is a thin client for the Keycloak Admin REST API: endpoints like realms, users, clients and groups map directly to REST paths.After config credentials stores an access token in the config file, subsequent commands reuse the session until it expires. Attributes are set with -s or supplied as JSON with -f.
PARAMETERS
--server URL
Server URL to log in to (config credentials).--realm REALM
Realm to authenticate against.--user USER, --password PASS
Login username and password; the password is prompted for or read from KC_CLI_PASSWORD if omitted.--client ID, --secret SECRET
Client ID (default: admin-cli) and client secret for service account login.-r, --target-realm REALM
Realm to operate on, if different from the login realm.-s, --set NAME=VALUE
Set an attribute in the request body.-f, --file FILE
Read the JSON body from a file, or stdin with -.-q, --query NAME=VALUE
Add a query parameter to the request.-F, --fields FILTER
Output only the given JSON fields.--format FORMAT
Output format: json (default) or csv.-o, --offset N, -l, --limit N
Paging for get requests.-i, --id
Print only the id of a created resource.--config FILE
Config file (default: ~/.keycloak/kcadm.config).--no-config
Do not load or save a config file; authenticate per command.--insecure
Disable TLS certificate validation.-x
Print a full stack trace on error.
COMMANDS
config credentials
Authenticate and store a session in the config file.config truststore
Configure a truststore for TLS connections.create ENDPOINT
Create a resource (realms, users, clients, groups, roles, ...).get ENDPOINT
Get one or more resources.update ENDPOINT
Update a resource.delete ENDPOINT
Delete a resource.get-roles, add-roles, remove-roles
List, add or remove realm or client roles of a user, group or composite role.set-password
Reset a user's password.help [command]
Show help for a command.
CAVEATS
Requires Java and a running Keycloak server reachable over HTTP(S). Since Keycloak 17 (Quarkus), server URLs no longer include the /auth context path. Passing passwords on the command line exposes them in shell history; prefer the prompt or environment variables. The config file contains tokens and should be protected.
HISTORY
kcadm.sh is the official admin CLI for Keycloak, the open-source identity and access management solution started by Red Hat in 2014.
