- ✅ User
dalekurtmconfigured withPASSWORD NULL(certificate-only authentication) - ✅ 3 trusted CA certificates uploaded to CockroachDB Cloud:
CN=amazingduck-dev-use1-self-signed-caCN=amazingbadger-shared-use1-self-signed-caO=teleport.sharedservices.frame.io, CN=teleport.sharedservices.frame.io
For the easiest setup experience, use the complete automation script:
./scripts/cockroachdb/auth/setup-passwordless-login.sh --username dalekurtmThis script will:
- Configure user with
PASSWORD NULL - Generate client certificate (if needed)
- Test connection
- Provide connection instructions
# 1. Ensure you're on the correct cluster
kubectl config use-context teleport.sharedservices.frame.io-amazingbadger-shared-use1
# 2. Extract CA certificate and key
mkdir -p certificates/clients
kubectl get secret amazingbadger-shared-use1-ca-secret -n cert-manager -o jsonpath='{.data.ca\.crt}' | base64 -d > certificates/clients/ca.crt
kubectl get secret amazingbadger-shared-use1-ca-secret -n cert-manager -o jsonpath='{.data.tls\.key}' | base64 -d > certificates/clients/ca.key
# 3. Generate client private key
openssl genrsa -out certificates/clients/dalekurtm.key 2048
chmod 600 certificates/clients/dalekurtm.key
# 4. Create certificate signing request
openssl req -new -key certificates/clients/dalekurtm.key -out certificates/clients/dalekurtm.csr -subj "/CN=dalekurtm"
# 5. Sign certificate with CA
openssl x509 -req -in certificates/clients/dalekurtm.csr \
-CA certificates/clients/ca.crt \
-CAkey certificates/clients/ca.key \
-CAcreateserial \
-out certificates/clients/dalekurtm.crt \
-days 365
# 6. Clean up sensitive files
rm -f certificates/clients/ca.key certificates/clients/dalekurtm.csr certificates/clients/ca.srl# Switch to amazingduck cluster
kubectl config use-context teleport.sharedservices.frame.io-amazingduck-dev-use1
# Extract CA (same steps as above, but use amazingduck secret names)
kubectl get secret amazingduck-dev-use1-ca-secret -n cert-manager -o jsonpath='{.data.ca\.crt}' | base64 -d > certificates/clients/ca.crt
kubectl get secret amazingduck-dev-use1-ca-secret -n cert-manager -o jsonpath='{.data.tls\.key}' | base64 -d > certificates/clients/ca.key
# Then follow steps 3-6 above./scripts/cockroachdb/auth/setup-passwordless-login.sh --username dalekurtmStep 1: Configure User
./scripts/cockroachdb/auth/configure-user-passwordless.sh --username dalekurtmStep 2: Generate Certificate
./scripts/cockroachdb/certificates/generate-client-cert.sh --username dalekurtm --ca amazingbadger --output-dir certificates/clientsStep 3: Connect
./scripts/cockroachdb/auth/connect-cockroachdb.sh --username dalekurtmThe scripts will guide you through the process interactively.
If Teleport has a database resource configured for CockroachDB:
# List available databases
tsh db ls
# Connect (Teleport handles certificates automatically)
tsh db connect massdriver-development-crdbNote: This requires the Teleport database resource to be configured and accessible.
Once you have the certificate files (dalekurtm.crt and dalekurtm.key):
./scripts/cockroachdb/auth/connect-cockroachdb.sh --username dalekurtmThis automatically includes all required certificate parameters.
cockroach sql --url "postgresql://dalekurtm@massdriver-development-s4k.aws-us-east-1.cockroachlabs.cloud:26257/massdriver_development?sslmode=verify-full&sslrootcert=$HOME/Library/CockroachCloud/certs/1ed91ecb-08a2-4886-b724-ddcd7bda41c3/massdriver-development-ca.crt&sslcert=certificates/clients/dalekurtm.crt&sslkey=certificates/clients/dalekurtm.key"export PGSSLCERT=certificates/clients/dalekurtm.crt
export PGSSLKEY=certificates/clients/dalekurtm.key
export PGSSLROOTCERT=$HOME/Library/CockroachCloud/certs/1ed91ecb-08a2-4886-b724-ddcd7bda41c3/massdriver-development-ca.crt
psql "postgresql://dalekurtm@massdriver-development-s4k.aws-us-east-1.cockroachlabs.cloud:26257/massdriver_development?sslmode=verify-full"export COCKROACH_SSL_CERT=certificates/clients/dalekurtm.crt
export COCKROACH_SSL_KEY=certificates/clients/dalekurtm.key
export COCKROACH_SSL_ROOT_CERT=$HOME/Library/CockroachCloud/certs/1ed91ecb-08a2-4886-b724-ddcd7bda41c3/massdriver-development-ca.crt
cockroach sql --url "postgresql://dalekurtm@massdriver-development-s4k.aws-us-east-1.cockroachlabs.cloud:26257/massdriver_development?sslmode=verify-full"- ✅ Ensure user has
PASSWORD NULL:Or manually:./configure-user-passwordless.sh --username dalekurtm
SELECT usename, passwd IS NULL FROM pg_shadow WHERE usename = 'dalekurtm'; - ✅ Verify certificate CN matches username exactly:
openssl x509 -in certificates/clients/dalekurtm.crt -noout -subject - ✅ Ensure certificate is signed by one of the 3 trusted CAs
- ✅ Important: Connection string must include
sslcertandsslkeyparameters. Use./connect-cockroachdb.shto ensure correct connection string.
- ✅ Verify the CA certificate is uploaded to CockroachDB Cloud:
./scripts/cockroachdb/certificates/check-cockroachdb-ca-cert.sh --cluster massdriver-development --api-key <API_KEY> - ✅ Wait a few minutes after uploading CA certificate for changes to propagate
- ✅ Ensure you're connected to VPN or have network access to the PrivateLink endpoint
- ✅ Verify DNS resolution:
dig massdriver-development-s4k.aws-us-east-1.cockroachlabs.cloud
⚠️ Never commit private keys (*.keyfiles) to git⚠️ Delete CA private keys after generating client certificates⚠️ Set proper permissions:chmod 600 certificates/clients/*.key⚠️ Rotate certificates periodically (default validity: 365 days)
- Complete Setup Guide: See
passwordless-login-setup.mdfor comprehensive documentation - Scripts:
scripts/cockroachdb/auth/setup-passwordless-login.sh- Complete automated setupscripts/cockroachdb/auth/configure-user-passwordless.sh- Configure usersscripts/cockroachdb/certificates/generate-client-cert.sh- Generate certificatesscripts/cockroachdb/auth/connect-cockroachdb.sh- Connection helper