- .
- .
Authentication configuration
CockroachDB allows fine-grained configuration of which database connection attempts it allows to proceed to the authentication stage, and which authentication methods it accepts, based on:- Who is making the attempt (SQL user).
- Where on the internet (IP Address) the attempt is coming from.
server.host_based_authentication.configuration , using the , which accepts a single text field that must be a correctly formatted HBA manifest. Inspect the current setting with
Supported authentication methods
All options also support the following no-op ‘authentication methods’, which do not perform authentication:
reject: unconditionally rejects the connection attempt.trust: unconditionally accepts the connection attempt.
HBA configuration syntax
Each line of a Host-based Authentication (HBA) configuration manifest defines a rule. Lines commented with# are ignored.
For example, the following naive configuration has three rules:
- User
ceocan connect to the database from a known IP address without a password. - User
sabateurcannot connect from anywhere. - All users (including
ceobut notsabateur) can connect from anywhere using a password.
- Each line must begin with a connection TYPE. CockroachDB currently supports two connection types:
localhost(any remote host)DATABASE, which defines the name of the database(s) to which the rule will apply. Currently, CockroachDB only supports cluster-wide rules, so the value in this column must beall.USER, which defines the username to which the rule applies. CockroachDB requires all connection requests to include a username. If the presented username exists in thesystem.userstable and has theLOGINoption enabled, CockroachDB will check the authentication configuration to find an allowed method by which the user may authenticate. This parameter can also take the valueall, in which case it will match all users.ADDRESSspecifies the IP range which the rule will allow or block, either with the keyword “all”, or with a valid IP address. The IP address can include an IP mask (the value of the field can be of the format XXX.XXX.XXX.XXX/X), or not, in which case the next value must be the mask (the value of this field will be of the form XXX.XXX.XXX.XXX, in which case the next field must be a valid IP mask).IP MASK(unless the Address in the prior field included or did not require an IP mask).- Authentication METHOD by which specified user(s) may authenticate from specified addresses.
password: user may authenticate with a plaintext password.scram-sha-256: user may authenticate viacert: user may authenticate with a PKI certificate signed by a trusted certificate authority CA.cert-password: user may authenticate with either a certificate or a password. Additionally, the server may use a exchange, if the cluster settingserver.user_login.cert_password_method.auto_scram_promotion.enabledis set totrue.cert-scram-sha-25: user may authenticate with either a certificate or a exchange.gss: user may authenticate with a GSSAPI token.ldap: user may authenticate using -compatible directory services, such as Microsoft Entra ID and Active Directory.reject: server unconditionally rejects connection without performing authentication.trust: server unconditionally allows connection without performing authentication.
The root access rule
By default, the root SQL user can always authenticate using username/password or certificate, as if the first rule of the configuration were:
Disabling root login
This feature is in and subject to change. To share feedback and/or issues, contact Support.
root user login using the --disallow-root-login flag when starting nodes. When this flag is set:
- The
rootuser cannot authenticate via SQL or RPC connections - Any certificate with “
root” in the CommonName or SubjectAlternativeName is rejected - Error messages indicate root login has been disallowed
Important Prerequisites:
- Before disabling
root, ensure you have at least one other user with the configured. Once root is disabled, you will need another admin user to perform administrative tasks. - Before disabling
root, it is highly recommended to set up thedebug_userfor troubleshooting operations. See Using debug_user for diagnostics. - Ensure no cluster or client certificates contain “
root” in their SAN (Subject Alternative Name) fields, as these will be blocked.
admin role or that debug_user is configured before allowing root to be disabled.Using debug_user for diagnostics
This feature is in and subject to change. To share feedback and/or issues, contact Support.
debug_user is a special privileged user designed for collecting and data when root is disabled. Unlike root, debug_user:
- Must be explicitly enabled using the
--allow-debug-userflag oncockroach start - Is disabled by default for security
- Must be manually created using
CREATE USER debug_user - Requires a certificate with “debug_user” in CommonName or SubjectAlternativeName
- Has privileged access to
serverpbadmin and status endpoints required for debug zip and tsdump collection - Can be audited using
SHOW USERS
debug_user is not subject to the --disallow-root-login flag and provides a secure, auditable alternative for these diagnostic operations.
CockroachDB Advanced or CockroachDB self-hosted customers can and should enforce network protections, preventing access attempts from any sources other than a valid ones such as application servers or a secure operations jumpbox.
Default behavior
CockroachDB Standard and CockroachDB Basic
The default authentication configuration for CockroachDB Standard and CockroachDB Basic clusters is equivalent to the following configuration:CockroachDB Advanced
CockroachDB Advanced clusters enforce IP allowlisting. Each cluster has an allowlist, which is configured through the CockroachDB Cloud Console. See .CockroachDB
CockroachDB deploys with the following default HBA configuration:Access for SQL health monitoring
CockroachDB Cloud uses a service user namedmanaged-sql-prober that regularly runs SELECT 1; queries on the cluster to monitor and report issues with SQL availability. The default host-based authentication configurations allow this service user to run, but more restrictive HBA configurations may prevent SQL availability monitoring. To explicitly enable this service user to authenticate, add the following line to your HBA configuration:
Disable root login and use debug_user
This procedure shows how to configure a cluster to disable root login for compliance requirements while maintaining the ability to collect debug zip and tsdump data.While it is possible to disable root login without first setting up
debug_user, enabling debug_user later when diagnostic data is needed requires a rolling restart of all cluster nodes. This can add a significant delay during troubleshooting incidents.Cockroach Labs recommends setting up debug_user before disabling root login to ensure diagnostic capabilities are immediately available when needed.Before you begin
To complete this process, you will need:- An existing CockroachDB cluster.
- Admin privileges to create users and grant roles.
- Access to the CA key to generate certificates.
Important: Ensure you have at least one other user with the besides
root before proceeding. Once root is disabled, you will need another admin user to perform administrative tasks. Without this, you risk losing administrative access to your cluster.Step 1: Create debug_user
-
Connect to the cluster as a user with admin privileges (such as
root): -
Create user
debug_user: -
Grant the
adminrole for debug zip collection.Whilecockroach debug tsdumpdoes not require any SQL privileges, theadminrole is required forcockroach debug zip. Cockroach Labs recommends granting it todebug_userwhen the user is created to ensure that the debug zip capability is immediately available when needed. Alternatively, another admin user can grant this role when needed.
Step 2: Generate debug_user certificate
Generate a client certificate for debug_user. Refer to for detailed instructions.
client.debug_user.crt and client.debug_user.key in the certs directory.
Step 3: Test debug_user access
Before disabling root, verify that debug_user can collect debug information:
Step 4: Enable debug_user on all nodes
Perform a rolling restart of all nodes with the --allow-debug-user flag:
Step 5: Disable root login
After all nodes have been restarted with--allow-debug-user, perform another rolling restart with the --disallow-root-login flag:
Step 6: Verify configuration
-
Verify
rootis blocked: -
Verify debug_user works:
-
Verify debug zip collection:
Security best practices
- Monitor
debug_useractivity through audit logs - Rotate
debug_usercertificates regularly - Ensure
debug_usercertificate files have appropriate permissions (mode 0700) - Store
debug_usercertificates securely and limit access to authorized personnel
Troubleshooting
Error: “failed to perform RPC, as root login has been disallowed”- Root login is disabled. Use
debug_userinstead.
- The
--allow-debug-userflag is not set on the server. Restart the node with this flag.
- Either the
debug_usercertificate is invalid or--allow-debug-useris not set. - Verify the certificate has “debug_user” in CommonName or SubjectAlternativeName.

