Private Mercurial Hosting

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up private mercurial hosting by running Mercurial over SSH or HTTPS. You then add user keys or passwords to control who reads and writes code. Most engineering teams start by placing their code folders on one Linux server. They create shared system accounts or basic web server rules for the team. When these roles stay too broad, any developer can change critical history. Broad access also lets users push bad commits to protected release branches. How to set up private mercurial hosting

Virtual Private Database: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up private mercurial hosting by running Mercurial over SSH or HTTPS. You then add user keys or passwords to control who reads and writes code. Most engineering teams start by placing their code folders on one Linux server. They create shared system accounts or basic web server rules for the team. When these roles stay too broad, any developer can change critical history. Broad access also lets users push bad commits to protected release branches.

How to set up private mercurial hosting architecture

Teams choose between two main paths when they build a private code server. The first path uses SSH keys to let developers log in and push changes. Each developer sends a public key to the server admin for setup. The admin adds that key to a central file on the host machine. When the user runs a command, SSH checks the key and starts Mercurial. The system can restrict that key so it only runs the repo command. This stops the user from opening an interactive shell on the server.

The second path runs the built-in Mercurial web CGI script behind an HTTPS server. In this design, the web server handles the login step for each user. It checks usernames and passwords against a local file or a directory service. Once the user logs in, the web server passes the request to Mercurial. Inside the repo settings, admins list which users can read or push changes. Teams can also add server hooks that run scripts before a commit lands. These hooks check branch names or reject changes that break team rules.

What native repository access controls solve and miss

Built-in SSH and web rules solve the basic problem of outside access. They keep public internet users from reading your private source code files. They also let you split your team into readers and writers with ease. A junior developer or build bot can pull code without having write rights. Server hooks add another layer by checking commit messages or branch rules.

Still, this native setup leaves a major operational gap for growing teams. Standard SSH and web logins only check who starts the session at the door. Once a user has write rights, they often keep those rights all day. Static SSH keys sit on developer laptops for months without rotation or review. If an attacker steals a laptop key, they gain full write access right away. Also, basic web logs and SSH logs rarely show clear, tied audit trails. Admins struggle to match a system login to the exact repo command run. Maintaining custom hook scripts across dozens of repos also takes hours of manual work.

Virtual Private Database: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing server maintenance and SSH key sprawl

As your team grows, tracking static SSH keys becomes a daily chore. People join the team, change roles, or leave the company every single month. Each change means an admin must edit key files on the host server. If an admin forgets one key, an old contractor keeps access to code. Shared group accounts make this problem even worse for security and audit teams. When five people share one SSH account, the server log shows one name. You cannot tell which person pushed a breaking change or deleted a branch.

Teams also face issues when admins need shell access to fix broken repos. Admin users often log in as root to run repair commands or edit hooks. During that session, no system checks individual commands before they run on disk. One bad command can wipe out commits or break file permissions for everyone. Putting strict, central controls around both repo traffic and admin sessions fixes this gap.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should I use SSH or HTTPS for private mercurial hosting?

SSH works well for small teams that already manage developer public keys. HTTPS fits larger teams that want to link logins to a central directory.

How do I stop users from pushing to a release branch?

You can add a pre-commit hook script inside the central repo settings file. This script checks the branch name and blocks pushes from unauthorized users.

Why are static SSH keys risky for code hosting servers?

Static keys do not expire on their own and remain valid on laptops. If a key leaks, anyone can pull or push code until you delete it.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.