The Simplest Way to Make Spanner and Ubuntu Work Like They Should
Using spanner and ubuntu together lets Linux servers run apps backed by a global cloud database. Your apps on Ubuntu send read and write queries to Google Cloud Spanner over encrypted links. This setup helps teams build fast systems that scale across many regions at once. Yet linking local or cloud Linux machines to a managed database brings clear security challenges. How logins and data flow between spanner and ubuntu Ubuntu servers need a valid cloud identity to talk to a Spanner database i
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Using spanner and ubuntu together lets Linux servers run apps backed by a global cloud database. Your apps on Ubuntu send read and write queries to Google Cloud Spanner over encrypted links. This setup helps teams build fast systems that scale across many regions at once. Yet linking local or cloud Linux machines to a managed database brings clear security challenges.
How logins and data flow between spanner and ubuntu
Ubuntu servers need a valid cloud identity to talk to a Spanner database instance. Most teams install the cloud command line tool or use client libraries inside their app code. The app on Ubuntu requests a token from Google Cloud IAM before it sends any query. IAM checks the identity and returns a token with a set list of database permissions.
When the Ubuntu host runs inside Google Cloud, it can use an attached service account. The host gets tokens from the local metadata server without storing static key files on disk. When Ubuntu runs in another cloud or data center, the login flow changes quite a bit. Teams often turn to workload identity federation or downloaded service account keys to log in. Once logged in, the client opens sessions to read and write rows in Spanner tables.
Common failure modes and how to scope roles
Many teams take shortcuts when they set up database links on Linux machines. A common mistake is putting a long-lived JSON key file onto an Ubuntu server. If an attacker reads that disk, they can take the key and query the database from anywhere. Shared service accounts create another big problem for security and operations teams.
When ten engineers log into one Ubuntu box, they often share one local Linux user. Any database query they run from that machine looks like it came from the same cloud account. Audit logs show the machine role, not the specific person who ran the delete statement. Broad roles make this worse because one compromised Ubuntu host can drop tables or read private records.
To fix these risks, start by removing static key files from every Ubuntu machine. Give each app its own narrow cloud role that only reaches the tables it needs. Split read roles from write roles so reporting scripts cannot change production data. Lock down network paths by using private cloud networks instead of public endpoints. Ensure every query ties back to a real user identity for clean audit logs.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Managing engineer queries and production data safety
Apps are not the only things that query Spanner from an Ubuntu work machine. Engineers often use Linux desktops or remote Ubuntu servers to check data and fix bugs. Giving every developer a persistent cloud role with raw table permissions creates high risk. People forget to revoke temporary roles after an incident ends.
Teams should require approval workflows before anyone runs manual queries against live production tables. You can also apply data masking to protect private fields during fixing sessions. For example, masking rewrites matched fields in results like emails, phone numbers, and card numbers. This lets engineers check app state and fix broken rows while keeping sensitive customer data safe.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
How should an Ubuntu server outside Google Cloud log into Spanner?
Use workload identity federation to trade your local platform token for a short-lived Google Cloud token. This avoids storing static service account JSON keys on the Ubuntu disk.
How do we restrict what an Ubuntu app can do in Spanner?
Create a dedicated IAM service account for that single app and grant fine-grained database roles. Give read-only permissions to apps that only fetch data and never need to write.
Why do our Spanner audit logs fail to show which engineer ran a query?
Your engineers likely share one service account or one Linux user on the Ubuntu host. Require individual user logins so every database query links to a real person.
Related guides
In this post