r/devops • u/Successful-Ship580 • Aug 22 '26
Discussion How do real companies securely give developers access to the development database?
Hey everyone,
I’m currently managing a small startup project. Our infrastructure is pretty simple right now: we have a single Oracle Cloud VM running our backend API and two PostgreSQL databases (one for dev and one for prod) inside Docker containers.
Up until now, I’ve been using DBeaver with an SSH tunnel to connect to the databases from my local machine.
Now, I need to bring another developer onto the project and give them access to the dev database so they can work.
I know sharing my private SSH key is a massive security no-no. But if I ask for their public SSH key and add it to my server's authorized_keys folder (for the main ubuntu user), doesn't that give them full SSH/sudo access to the entire server? That feels like overkill just to let them run SQL queries.
For those of you working in the industry or scaling startups: What is the standard, real-world way companies handle sharing database access with developers?
Do you:
Create a restricted Linux user specifically for SSH tunneling?
Put the database behind a VPN like Tailscale?
Expose the port directly but heavily restrict the IP firewall?
Use something else entirely (Bastion hosts, Teleport, etc.)?
Since we are a small team with a limited budget, I'm looking for the sweet spot between "enterprise-grade security" and "easy enough to set up today."
Would love to hear how you all handle this in the real world! Thanks!
155
u/road_laya Software Engineer Aug 22 '26
I spin up a development server in their dev environment on their local machine with Docker. The simplest would be something like using the docker compose functionality of dev containers.
101
u/HelicopterUpbeat5199 Aug 22 '26
There shouldn't be "a" development database. You should have a dataset for dev use or something that generates fake data. Everyone should get their own database. You should never have the productivity of Alice be at the mercy if Bob's shitty sql code. By that I mean, if one if you drops the tables, the rest of you are going to twiddle your thumbs.
43
u/Resident-Librarian-6 Aug 22 '26 •
If you're not wanting to have anything too complicated, create a dev user/ssh key with restricted access to the server, and give the devs a built in db role with the level of access you want to grant. Currently we host our dbs/server in azure, use their RBAC and usually the generated connection string from the terraform output for devs to connect.
26
u/Old_Bug4395 Aug 22 '26
At a certain size, most people are using a cloud service like GCP or AWS or similar to manage their database and then access is managed by IAM. In a startup environment a lot of people do just give a developer full access to the development environment, and even sometimes production too. I don't necessarily think that's a great solution so if you want to continue with your current infrastructure (running the dbs in docker), I would just make a user account for the dev, or expose the port on an internal network. I'm not very experienced with oracle but you can probably set up a VPN into the internal network you're running your VMs on.
5
u/floodedcodeboy Aug 22 '26
Why so precious about a dev db? Surely it can be run locally? And don’t forget to seed your dev db with Fake data - no need to host a dev db in the cloud.
4
u/sfboots Aug 22 '26
We create a database subset and developers use a local db for 90% of their work. They do get access to the shared dev environment since they need to deploy their code and test
4
u/Global_Car_3767 Aug 22 '26 edited Aug 22 '26
Our databases are in AWS with IAM permissions tied to KMS keys that get injected into our application repository's secrets portal. Every member of a team has to be a part of a specific LDAP group to be able to copy and paste the redacted secrets from the repos their team owns. All developers on the team have access to non-prod secrets, senior members have prod access but need to create an incident ticket to get those secrets for auditing purposes. In both instances, there are many teams with many repos and we can't just grab secrets to other teams' apps.
4
u/svengoolies Aug 22 '26
Teleport
16
u/maikeu Aug 22 '26
99% of the time, they shouldn't need to access the dev database. Postgresql is trivial to run on their own machine, and there are plenty of database schema management/ migrations frameworks they can use to safely define the evolution of the db schema.
11
u/JCii Aug 22 '26
Using a shared DB for dev is going to bite eventually. All dev infrastructure should be ephemeral. The same process that creates it on a localdev machine should create it for your CICD pipeline, for every run. Long lived testing DBs will lead to inconsistent results in your testing pipeline.
Have AI build this out for you.
3
u/Prudent-Stress Aug 22 '26
If dev means their own machine, just spin a mysql/postgres:whaver engine you have.
If dev means the actual infra environment… from my experience comp that use Azure / GCP / AWS will just do role based authentication, no passwords, no rotation, easier to audit
3
u/KittensInc Aug 22 '26
Ephemeral database on the developer's own machine. Most mature languages / IDEs will have some way to spin up a DB container on-demand via something like Docker Compose.
Track database migrations via something like Flyway so it it trivial to re-establish the database's scheme on app startup, then add a "seed" file to your application which does an "if tables empty: add a bunch of dummy data".
Ruby on Rails is the perfect example of what this looks like in a batteries-included framework, both when it comes to migrations and seeding.
3
u/fearless-fossa Aug 22 '26
If you do this because the db isn't reachable from your clients, you'll want a bastion server and use that as a go-between, at least in the long run. Otherwise just create a new user for them on the server where they can login via their own key, but never share users between people.
3
u/creativemind11 Aug 22 '26
We let people run dev databases that contain mock data on their own pc. Usually Docker containers.
2
u/vacri Aug 22 '26
Create a user account for them on that machine and put their ssh public key on that. Don't give their account sudo rights. Job done - they can ssh in and do all the things an unprivileged user can do. And when they leave the company, you turn off that account.
In general, you want to avoid shared logins, even in small companies. Put Single Sign On / SSO everywhere that's feasible for you, and separate logins for everything else. That way when staff leave, there's no "we can't rotate that password because it's in use at X, Y, Z", you just turn off the user accounts.
As for databases, you generally want them behind a VPN or bastion host. If you give them a public IP and direct access on the internet, you have the risk of a messed-up firewall rule allowing unexpected access.
This is the right attitude to have. You can't do best practices security right out of the gate, not in the real world. But you can cover most bases and then improve as you go along. Setting up security functions takes time, especially when you're not familiar with the details - just don't forget to keep improving as time goes on.
Remember you also need to secure data that might be compromised if a dev's laptop is stolen/lost/compromised. Anywhere your data goes, you need to plug into your threat model and figure out how risky you want to be with it.
2
u/pdfops Aug 22 '26
Skip the SSH-key-on-the-server approach entirely if you can, put Postgres behind Tailscale and give the new dev a dev-scoped Postgres role with grants only on the dev schema. No SSH needed at all. If you want to keep the jump host, don't hand out a real login, restrict the key in authorized_keys with no-pty,no-agent-forwarding,no-X11-forwarding,permitopen="localhost:5432" so that key can only forward the DB port and never gets a shell or sudo.
2
u/OmegaNine DevOps Aug 22 '26
We don’t. For fucks sake they would take us down every day. We copy back to staging and give them access there. If they need live data they have to come to us and we will get them the data.
1
u/Adventurous_Job9209 Aug 22 '26
Man this is a great question. I’m still mid level so I’m sure some more senior guys have a way better answer. I first thought of hashicorp vault but it might be overkill for your company size. I think creating the restricted linux user is probably the easiest way but doesn’t scale well. Putting in behind a vpn is probably a better way because then you can eventually add vault and have rotating creds with a short ttl. Tough to say, I’m interested in others input.
1
u/follow-the-lead Aug 22 '26
alright there’s a lot of options offered here, but here’s my take and something worth considering.
block everything except yours and your dev IP addresses to begin with.
Things like user logging is a lot easier to maintain if you split out the accounts for example.
1
u/eightlegfriend DevOps Aug 22 '26
It might be better to have your dev database and production database on different hardware, in different networks.
1
u/huzzyz Aug 22 '26
Overlay VPN (tailscale) with ACL setup properly would be my goto. I am managing just 2 nodes with 25 dev's main is netbird self hosted and tailscale for fall back.
1
u/donjulioanejo Chaos Monkey (Director SRE) Aug 22 '26
Our access is somewhat hacky but honestly scalable.
Database access goes through postgres shell in a special toolset container that runs in EKS...
But we have AWS SSO and every environment gets its own AWS account.
If you have access to the AWS account and EKS with exec privileges, you can access the database as well.
1
u/AlaskanX Aug 22 '26
I have RDS in the prod AWS account which nightly gets synced to RDS in the dev account via snapshots, and weekly ( or on schema changes ) I back up a dump into S3. I’m the only person with access to RDS, and everyone including me syncs with the copy on S3 for their local docker instance.
1
u/ForkMeJ Aug 22 '26
For a setup this small, I would not give shell access only to reach Postgres. Adding their key to the main ubuntu user gives them far too much access for "run some queries." Give them a path to the dev DB and a separate DB user with only the permissions they need there. If they only need to inspect or modify app data in dev, that account should not be able to touch prod, manage the host, or do broader admin work in Postgres.
I'd lean toward a VPN before exposing the database port to the internet, even with an IP allowlist. Tailscale or WireGuard is a reasonable small-team answer, and it lets Postgres stay on a private address. If you stay with SSH tunneling, create a separate Linux user with no sudo and no shared access to the main account. The main thing is not to bundle server access, network access, and database permissions into one credential.
1
u/Ebrithil_7 Aug 22 '26
I think tailscale or personally my fav is Pangolin, works best here. You only expose the dB port on your local network, have a public resource domain name that tunnels the traffic. No ports exposed publicly. You can even enforce 2FA for connecting.
1
u/Long-Ad226 Aug 22 '26
We run postgres with cnpg at scale for multiple customers, there is pgadmin with SSO in front, so devs can use their standard azure ad account for getting access to postgres, permissions handled via azure ad groups.
1
u/gilmorenator Aug 22 '26
Our devs use docker-compose orchestrated via paver.
It has a bootstrap with all common configs and a data generator. Use local stack for AWS services.
1
u/UkrMalt Aug 22 '26
At this size I’d separate host access from database access. Give each developer a non-sudo account and a per-person Postgres role, then keep the DB on a private network or VPN. I’d also seed a local DB for most work so the shared dev instance isn’t the only path; offboarding then means disabling one account instead of rotating a shared key.
1
u/Individual-Oven9410 Aug 22 '26
Earlier I used bastion host but then moved to Zscaler SASE (ZPA)
1
u/Patex_ Aug 22 '26
We got a docker container and local databases for development. On the dev system the user is only accepting local host connections which you can access via a wireguard vpn tunnel.
Everyone has their own wireguard key pair, the database user and password is shared but as you need server access in the first place this is fine.
There are countless other ways how to do it, we choose this as we needed a vpn for a static IP in many cases anyways.
1
u/engineerL Aug 22 '26
Postgres is inside k8s. K8s RBAC governs who can port forward in. Postgres 18 OAuth governs who can actually authorize to the DBMS, and what they can do when inside. You'll need some neat platform abstractions in the first place for any of this to be tractable and maintainable.
1
u/a_sad_fat_man Aug 22 '26
From an infra engineer perspective, there are two types of "dev" envs and I think you need both..
All local and you don't have to worry about stepping on another dev's toes working in the same DB. If you break something, who cares, just tear it down and rebuild it (ideally everyone has a way to easily spin up a local copy).
2. Then there's "the dev environment" which is the more persistent thing you're talking about. Matches Prod and everyone deploys their final changes here for integration testing, etc. after having success in their local "pre-dev" env.
Tailscale (or something like it) is what I'd go with. VPN is the best thing you could do if you want the security folks to be happy. Don't expose your db publicly, even if it's just dev.
The dedicated linux user for port fwd/ssh tunneling fits too as the next best/easy thing in this case. No shell access and smaller blast radius.
If your db supports it, ephemeral db credentials are the safest (AWS IAM auth, Vault dynamic creds, etc.). If that's not available, dedicated static db user(s) specifically for humans (separate from your app's db user)
1
u/durple Cloud Whisperer Aug 22 '26
Keeping dev environment local to dev machine is ideal. If there is a real reason (there usually isn't) for a shared database for developers, then one of those other options will be needed.
Which of these is going to be determined by your threat model and your budget for time and spend, and could include other options like having access go through a zero trust solution, or a cloud-specific option like Google's Cloud SQL Connection Proxy. They'll each have their trade-offs around cost, implementation effort, maintenance effort, etc. There is no standard real-world way, part of the job is deciding what option best fits the business need.
1
u/LaffingAtYuo Aug 22 '26
In a perfect world people are running the database locally and they contribute migration scripts for the integration environment that feed upstream to prod. Are you asking how they help troubleshoot production issues?
1
u/Electro_Nick_s Aug 22 '26
Just in time access. So the developer requests time boxed elevated access and it's removed after the time period
1
u/bobdvb Aug 22 '26
Everything behind a firewall that can be. Only expose ports that service customer traffic and even then use a CDN or WAF if possible.
Every user gets their own unique login credentials because otherwise you don't have audit traceability.
Remote access provided by ZTNA, you can use Tailscale, Cloudflare or Zscaler (or many others). Then you can validate any remote users, your own or contractors, and restrict what servers/ports they have access to.
All environments operate on the principle of least privilege. No one gets access to anything they don't have a good reason to.
No one gets access to production databases unless it's their job to access production data. The development database could be a replica unless it contains PII and PII shouldn't be in Dev environments (unless it's one way obfuscated).
1
u/Lacutis Aug 23 '26
So we do this another way.
All remote employees VPN into our office network. Office has a secure tunnel to Azure.
So devs VPN in and then use whatever client they want to hit the dev server.
We also have local db integration tests so that most things can be tested locally.
1
u/whyredFire Aug 23 '26
I'd spin up an Ubuntu container on the same Docker network as the dev DB pod and expose its SSH port on the host (say 2222, or any free port). Then they can simply SSH into that container and access the database through it.
1
u/Rohit_Verma_9911 Aug 23 '26
There's is misconception
1
u/dariusbiggs Aug 23 '26
Depends on the data, sensitivity, and use cases.
Mock non-sensitive data, importor generate locally into a docker container for their dev environment. (We do this)
Slightly more sensitive, give them their own dev environment in their own cloud account with budgets and restrictions in place. (We can do this if additional cloud resources are needed and to develop systems using cloud resources).
Shared resources, VPN to access the network. then their own credentials to connect to it. You can also do an SSH tunnel tied to their own Linux user, after which they can connect using whatever level of DB access credentials they need. (Certain staff have VPN access, and they can use SSH over that VPN via a bastion host with their own user accounts, which is backed by our SSO so the instance the user is deactivated their ability to connect ends and authorized keys are not stored on disk. Access control is heavily restricted as are their ability to use sudo powers, everything is audit logged, and there's a HIDS in play along with change detection that can isolate a machine. This environment is required for development testing and testing asthere are external factors preventing this data from being replicated to the developers themselves.)
There are so many ways to skin that camel, it all depends on what you are securing, what the data is. how it needs to be protected, etc.
Always look at it from a data protection and privacy perspective, then a least privilege perspective, and finally an ease of use perspective for the developers in question.
The only thing that is never an option is opening up the database port to the world. Doesn't matter if you restrict it with mTLS, creds, firewalls, etc. No database should ever be exposed to the world directly. One config mistake and you are screwed. Just eliminate that possibility in the first place, and put explicit blocks in place just in case. That way multiple mistakes must occur, otherwise it is malicious.
1
u/kabads Aug 23 '26
Give them a docker container of the machine that they can run. Simples.
1
u/jameshearttech Aug 24 '26
We have 4 environments: local, ci, test, and prod. Test and prod run cnpg. Local and ci use quarkus dev services to provide postgres. We periodically create an image that contains data from test cnpg, which is what dev services loads so we have actual data in local and ci. It lags test, but it's good enough. We can manually cut a new image at any time if needed.
1
u/ankitjindal9404 Aug 24 '26
We use redash
1
u/benelori Aug 24 '26
We use Bastion hosts in Azure, with SSH tunnels. If you start up SSH with -D, it can also create a SOCKS5 proxy for which you can configure to what domains should requests go through the tunnel and which to use normal internet.
Between Bastion host and the database the network traffic is within a private network.
One of the advantages of this setup is that in this way you can use Azure specific access control policies to control who has access.
1
u/Haunting-Banana8240 Sep 15 '26
adding their key to the ubuntu user is handing them root, your instinct is right.
but you're merging two things. they need sql access, not shell access. make them a non-sudo linux user thats not in the docker group, plus a pg role scoped to dev only. or put the db behind tailscale and skip ssh.
disclaimer, I work on the PAM side of things, so grain of salt. we put JumpServer in front of ours. devs connect to postgres through it, no server keys get passed around, and every session + query is recorded, so "who dropped dev on friday" has an answer. browser sql console, or DBeaver as a remote app if they want it.
for 1 vm and 2 devs though its overkill, revisit at ~5 devs.
1
u/rhshadowman Aug 22 '26
Boy.... I hope they have some sort of resilience in prod... is it just a singular docker container or what?
Good.
No it doesn't give them root access to the server. Or at least it shouldn't unless you have this setup. (major security risk).
Why don't you just give them an account that is not apart of the wheel group or passwordless sudo. Then maybe add them to a DB group that has DB access? Or even better, give them a user with no shell, still apart of the DB group, just so their DBeaver connects?
Typically, in my environments, I have a centralized auth setup that is scoped down to what the user is needing todo. But it seems that you don't have that? So if that is the case, then a local user that is extremely scoped down(like I stated above), then allow connections only on that port for SQL queries.
Sorta depends? I mean you can do it behind a VPN, or a gateway like setup. I guess this depends on how your work environment is setup. I know "It depends" is not what you want to hear. But there is no cookie cutter answer. Anyone that inherently says yes or no, is missing the mark by far.
Generally no. However, this also depends. CIS the system at minimum, then open up what is required. Same thing for the container/pods that you are running on in. Defense in depth type stuff. Implement IAM and fail2ban or faillock or something like that. Paried with a WAF, etc, etc. This is too broad to answer.
Baseline roll out the systems. Dont ever do things by hand. Templates everything with idempotent design. Spend the hours doing it up front, and thank yourself later on. Otherwise you will never succeed.
0
u/naseemalnaji-mcpcat Aug 22 '26
Founder of Opal Security here.
For an early team, I highly recommend Tailscale + a unique user credential on the database that expires in some amount of time.
It’s annoying, but honestly not much around it and it will get you past SOC 2 if you’re disciplined with who you grant it to.
0
u/Oleksii_Bebych Aug 22 '26
If we are talking about the AWS cloud , our standard practice is to deploy OpenVPN access server (because it's much cheaper than AWS managed Client VPN)
You can take a free license (AMI for 2 simultaneous connection) on AWS Marketplace). The OpenVPN instance is deployed in public subnet. People connect to it from their laptops and get connectivity to private resources like DB
0
u/jylusdev Aug 22 '26
We use the open-source version of NetBird on our stack. It’s easy to deploy and configure, secure, and gives us full control over the infrastructure. Tailscale is also a good option.
0
u/haloweenek Aug 22 '26
We have dev and pre environments ?