Selfhost Git
To selfhost git, you install a repo server on your own machine or cloud host. You then set up SSH keys, HTTPS certificates, and user roles for your team. Many engineering teams build this setup to keep full control over their source code. They pick a lightweight server app or a full code platform for their private network. Next, admins create user accounts and group roles to manage repo permissions. Still, admins often grant broad host permissions or shared SSH keys during the initial setup. Wh
Git Commit Signing (GPG, SSH): the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To selfhost git, you install a repo server on your own machine or cloud host. You then set up SSH keys, HTTPS certificates, and user roles for your team.
Many engineering teams build this setup to keep full control over their source code. They pick a lightweight server app or a full code platform for their private network. Next, admins create user accounts and group roles to manage repo permissions. Still, admins often grant broad host permissions or shared SSH keys during the initial setup. When roles are too broad, one stolen key can expose every repo and server file.
How to selfhost git at the architectural level
A private Git setup relies on three core layers to store and serve code. First, the storage layer holds the raw Git objects and bare repos on a disk. Second, the transport layer handles network traffic over SSH or HTTPS protocols. Third, the app layer gives users a web interface for pull requests and issue tracking.
When a developer pushes code, the client connects to the server over SSH or HTTPS. If the team uses SSH, the server checks the user public key against an authorized list. A dedicated system user, often named git, runs the shell command to receive the code. If the team uses HTTPS, the web server checks the user password or personal token. After the login check passes, the Git service checks the user role for that repo. Standard roles include read, write, and admin permissions for specific project groups. Finally, server hooks run custom scripts before or after the server saves the new commits.
What native Git hosting solves and what it leaves open
Running your own Git server solves major data residency and network isolation needs. Your source code stays inside your private network and is masked in responses before reaching a public cloud vendor. You also avoid per-user seat fees and strict rate limits on build pipelines. Native repo roles do a good job of controlling who can merge code into main branches.
Git Commit Signing (GPG, SSH): architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, the native app setup leaves a big operational gap on the host machine itself. Repo roles only check who logs into the Git app or pushes to a branch. They do not control what happens when an admin logs into the underlying Linux server. Admins still need direct SSH sessions or database access to run backups, upgrades, and fixes. Once an admin logs into the host shell, native Git roles cannot restrict their commands. A single bad command in the shell can delete repos or expose private keys. Also, standard server logs rarely capture every shell command or database query run during maintenance. If an engineer queries the app database, raw emails or phone numbers appear in the results.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Should I use a bare Git server or a full web app?
A bare server uses only SSH and disk folders, which works well for tiny teams. Most teams pick a web app to get pull requests, code reviews, and role controls.
How should we back up a self-hosted Git server?
You must back up both the bare repo folders on disk and the app database. Run automated daily snapshots and test restoring them to a clean host every month.
Is SSH or HTTPS better for Git client connections?
Both protocols are safe when you set them up with strong keys and modern certificates. Many teams prefer SSH keys for daily coding and short-lived HTTPS tokens for build runners.
Related guides
In this post