Skip to main content

Connect to an instance

--instance takes the region and the name, as REGION/NAME. bqto gives you a port forward. The local port is the port of the instance plus 10000, so 6379 becomes 16379. A Redis instance with TLS, on 6378, becomes 16378. With -- CMD, use redis-cli -h $BQTO_HOST -p $BQTO_PORT.

TLS and AUTH

With -- CMD, two variables tell your client what the instance needs:
  • BQTO_TLS is 1 when your client must use TLS, and empty otherwise.
  • BQTO_AUTH names the credential that the instance takes: password (an AUTH string), iam (an access token), or empty for none.
With TLS, the client needs the CA of the instance in server-ca.pem. On its CA: line, bqto prints the gcloud command that writes this file. With BQTO_AUTH=password, set REDISCLI_AUTH to the AUTH string of the instance before you start bqto. Put the client lines in a script, such as client.sh:
Then run it through the session:
Pass passwords and tokens through the environment or a private file, never as command-line arguments.
If transit encryption is off, an access token that you use as a password travels in cleartext from the bastion to the instance.

Clusters

Memorystore for Redis Cluster and Memorystore for Valkey in cluster mode need bqto Pro.
bqto knows when an instance is a cluster. For a cluster, it opens a SOCKS5 proxy instead of a port forward, because the client follows redirects to other nodes. The ready line prints the client command, such as proxychains4 -q redis-cli -c -h HOST -p PORT, with a proxychains.conf whose last line is socks5 127.0.0.1 PORT. BQTO_REMOTE holds the address to reach through the proxy.

What it needs

  • The API redis.googleapis.com for Redis, or memorystore.googleapis.com for Valkey, in the service project.
  • The role roles/redis.viewer for Redis, or roles/memorystore.viewer for Valkey, in the service project, together with the roles that every session needs. See Permissions.