- Who is making the attempt (SQL user).
- Where on the internet (IP Address) the attempt is coming from.
Why customize your authentication configuration?
CockroachDB Cloud clusters include industry-standard security controls at the network and infrastructure levels, and CockroachDB self-hosted may be deployed with any measure of network security one cares to put in place. Nevertheless, a hardened authentication configuration offers a powerful measure of security in depth. Limiting allowed database connections to secure IP addresses reduces the risk that your cluster is compromised, because a potential attacker who acquires database credentials (e.g., username/password combinations or client ) cannot use those credentials without also gaining infrastructure access. Infrastructure access can and should be protected with multifactor authentication and restricted to appropriate parties using infrastructure-level IAM.Step 1: Provision and access your cluster
. From the CockroachDB Cloud Console, select your new cluster and click the Connect button to obtain your connection credentials from the Connection Info pane in the CockroachDB Cloud Console. You’ll also need to download the cluster’s , so that your client can authenticate the database server as it connects. Open a SQL shell against your cluster.Step 2: Provision a secure jumpbox
By default, anyone who knows the parameters in this command can access your database. Let’s fix that by creating a jumpbox: a compute instance that will be used as secure, dedicated access point to our cluster. In this example, the jumpbox will be a Google Cloud compute instance (although you could as easily use an AWS EC2 instance) which allows us to protect access to the jumpbox with Google Cloud’s native capacities to require two-factor authentication for SSH access to compute instances, and to limit that SSH access to precisely those users that require it. By limiting SQL access to those actors who have SSH access to the jumpbox, we can effectively enforce two-factor authentication for access to the database, as well as take advantage of other security measures available on Google Cloud compute instances, such as access logs. In the Google Cloud Console Compute Instances page, create a new instance calledroach-jump-box. The jumpbox will need very little CPU or disk, so use a cheap instance such as an e2-micro.
In the Google Cloud Console VPC Network / External IP addresses page, reserve a static IP. Name it roach-jump-box, and attach it to the compute instance.
Keep the IP address handy!
Step 3: Tighten the authentication configuration
Next, we’ll configure our cluster to only allow SQL connection attempts from our jumpbox. This means that in order to access the cluster, someone will need not only the username and password (which could be guessed or stolen), but will also need access to the jumpbox. Manage permissions to access the jumpbox using Google Cloud’s IAM, and make sure that users in your Google Cloud organization are required to use two-factor authentication. Returning to the SQL console, let’s set our authentication configuration to limit access to the jumpbox. This configuration is accessed as a . RunSHOW CLUSTER SETTING server.host_based_authentication.configuration; to view your current authentication configuration, which should be in its default state, which displays as empty:
Step 4: Confirm the IP restriction
Exit the database shell by typing\q, and then try to re-establish the connection. This time the attempt will be rejected because we are not making the attempt from the sole allowed IP address.
Step 5: Access your cluster via the jumpbox
Finally, let’s attempt the connection from the jumpbox. You’ll need to usescp to transfer the cluster’s root to the jumpbox, so that your client there can use it to authenticate the server. Then shell into the jumpbox with the gcloud gcompute ssh and run your connection command from inside the jumpbox.

