Skip to content

feat: add pg-addadmin for remote admin roles#37

Open
coolaj86 wants to merge 1 commit intomainfrom
feat/pg-addadmin
Open

feat: add pg-addadmin for remote admin roles#37
coolaj86 wants to merge 1 commit intomainfrom
feat/pg-addadmin

Conversation

@coolaj86
Copy link
Copy Markdown
Contributor

Summary

  • Adds pg-addadmin script that creates a remote admin role with CREATEDB + CREATEROLE privileges
  • Adds a pg_hba.conf entry allowing the admin to connect to ALL databases (unlike pg-adduser users who are limited to sameuser)
  • Follows the same conventions as pg-adduser: prefix + random hex suffix, base58 password, member of remote_users group
  • Updates README with usage docs

This is needed for automation tools (like pmx-ng) that provision tenant databases remotely via an admin DSN. Run once per Postgres instance after pg-addgroup.

Test plan

  • Run pg-addgroup hostssl remote_users 15432 on a test instance
  • Run pg-addadmin admin 15432 remote_users and verify role is created with CREATEDB + CREATEROLE
  • Verify pg_hba entry allows admin to connect to postgres database (not just sameuser)
  • Verify admin can CREATE DATABASE and CREATE ROLE remotely
  • Run shellcheck on pg-addadmin (passes clean)

@coolaj86 coolaj86 force-pushed the feat/pg-addadmin branch 5 times, most recently from b2f03c7 to 8720574 Compare March 31, 2026 11:21
Creates a remote admin role with CREATEDB + CREATEROLE privileges and
its own admin_users group (created if it doesn't exist). pg_hba entries
allow access to ALL databases (not sameuser like remote_users).

Supports --host-networks (host entries, for private subnets behind a
TLS-terminating proxy) and --hostssl-networks (hostssl entries, for
shared/untrusted networks where TLS at the pg level is required).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant