Updated: 2026-10-31.
You want a shared place for code that you can move when your needs change. A private Git server can provide that, without a web application or a large set of services. The harder decision is who will look after it. Someone must remove lost keys, keep recovery copies and deal with the day an update or disk fails.
For one person or a small team with equal access, bare Git over SSH is a useful option to consider. This guide explains the design and the work it adds. The complete download contains the ordered commands, configuration, expected results and recovery procedures for the specific setup described here.
Does everyone need the same access?
Git keeps a project's history in a repository. In this design, each member edits a local copy, while the server stores a bare repository: the shared history and objects, without a working copy for editing. Secure Shell, or SSH, provides the encrypted connection and uses keys to identify the member and the server. This is a documented Git hosting pattern. Git server guide
Every approved member can read and write the same repository. That is the central assumption. It can suit colleagues who already trust one another with the whole project. It does not provide separate customer spaces, read-only roles or enforced review rules. The Git account's restricted shell accepts Git operations, but it is not a filesystem sandbox: keep it away from unrelated repositories. git-shell
If you need those finer controls, consider a forge: software that adds accounts, reviews and issues around Git. A self-managed forge brings more application data and maintenance. A hosted private forge transfers much of the server work to a supplier. Neither choice removes your responsibility for access, integrations, independent backups or the terms under which the service operates.
What does private hosting let you control?
The useful control is specific. You choose the repository's host, access keys, backup schedule and next destination. You still depend on the operating system, its package sources, the administrator and each member's computer. A rented machine also leaves trust with the infrastructure supplier.
An encrypted connection is only part of the privacy picture. SSH protects the transfer; it does not encrypt the repository files on the server's active disk. A copied repository remains a copy after you close its owner's access. A stolen member key or a hostile administrator can also defeat the intended privacy. OpenSSH server manual
Hosted private repositories remain a reasonable alternative. GitHub's terms, for example, treat private content as confidential with stated access exceptions. Those hosting terms do not establish that private repositories are used for model training. Optional AI features have their own policies and controls. GitHub terms, sections E and J
GitHub's current Copilot policy permits training use of individual-plan interaction data from 24 April 2026, with an opt-out, and states a different rule for Business and Enterprise data. Check the actual plan and settings. Keeping the repository on your own host does not stop an editor extension from sending code elsewhere. Copilot policy
The cost comparison therefore includes the maintainer's time as well as the host, network and independent backup storage. A small component set can reduce what you maintain. It does not guarantee lower cost or better security than a hosted service.
Prepare the network and recovery access first
The worked procedure uses a dedicated Debian 13 amd64 server, systemd and a local
filesystem. The administrator has a separate account with sudo and console recovery
access. Members use Linux clients with Bash, Git and OpenSSH. The account and
repository paths must be new; existing data or an existing git account is a
reason to stop and review the fit.
This is a private-network service. Its dedicated SSH listener uses the chosen private IPv4 address and TCP port 2222, with network rules that admit approved clients and deny public access. A private address alone does not enforce those rules. The procedure assumes the network already exists and leaves administrative SSH under its own access policy. It adds no public DNS, web port or TLS certificate.
Recovery also needs preparation before the first push. Arrange an independent, encrypted backup volume, keep its recovery key away from the server, and name who will restore the service. Allow space for repository growth, incoming pushes and temporary work. The reference gives a planning allowance, not a measured capacity promise.
Use the current security-supported Debian packages and record what was installed. The version numbers in the download are dated source observations, not a reason to hold back security updates. The preparation section in the complete download contains the exact assumptions, versions, paths and placeholder values. Git package, OpenSSH package
Give member keys and the server key different jobs
Each person gets a separate member key, even though everyone connects to the same Git account. The administrator installs the approved public keys and keeps control of the access file. The private keys stay with their owners. This lets access changes target one member without replacing everyone else's key.
The server has a different key: its host identity. A client checks that identity before sending code. The member must obtain its fingerprint through a known channel and compare it with the connection prompt. An unexpected mismatch is a stop condition, not a reason to disable checking. SSH key and host checks
The procedure gives Git a separate SSH service so closing Git access does not also remove administrative SSH. It disables general shell access, forwarding and several client-controlled features. Those controls need the stated account, file permissions and network rules together; one setting is not a substitute for the rest. Follow the complete server configuration and client identity setup. Server configuration manual
Once identity is established, the new sample repository receives its first commit. That is a one-time write. Later maintenance and recovery checks instead compare a fresh local copy with an accepted record of the expected history and refs, the names that point to Git objects. They must not replace a README or add a sample commit to restored production history.
The optional deletion check also has a narrow purpose. It creates a specifically authorized disposable branch, attempts to delete that branch and confirms the server rejected the deletion while leaving the same branch and object ID. The configured receive guards apply to branches in the cited implementation; they do not make tags immutable. The full first-use and repeat-check procedure keeps those actions separate. Git receive implementation
Close existing activity before backup or urgent revocation
Removing a member's key affects new logins. It does not establish that an older connection has closed. That distinction matters when a device is lost, and it also matters when the repository must stop changing for a backup.
The reference uses one stop procedure for urgent revocation, backup and retirement. With the owner's permission to interrupt the dedicated account, the administrator stops the Git listener, inspects and ends its registered login sessions, and checks remaining processes and TCP connections. These are separate observations. A service-unit stop covers its remaining processes; login sessions can occupy other scopes. An empty effective-user process list is not the whole inventory. Unit process control, session registration, session controls
Unclear state keeps the service closed. The procedure does not kill every SSH process, terminate the administrator or disable PAM. Where an authorized client connection was already open, its holder can confirm that it closed. A rejected new login is separate evidence. Use the complete stop and session checks, including their error conditions, before proceeding.
The backup then preserves Git history, access configuration and the private host
key on the prepared encrypted storage. The archive itself is not encrypted by
tar. Every write depends on successful safeguards and a new backup directory,
so an existing recovery copy is not overwritten after a failed check. Archive
creation never restarts the service automatically.
For an update, the service stays stopped after the accepted backup while package work proceeds. For a failed backup, reopening requires an explicit decision about the backup gap; it cannot waive unresolved session, identity or access checks. These details are why the backup and maintenance sequences should be read together.
Recover identity as carefully as history
A restore can bring back more than lost code. It can also bring back a revoked member key or a host key that was exposed after the snapshot. Recovery therefore starts on a separate, stopped target. The administrator checks the saved data, compares its refs and reconciles the access list against a current revocation record kept outside the restorable snapshot.
A host key can be retained only when its secrecy is accepted, with one active endpoint using that identity. Exposure or uncertainty requires replacement before startup. Clients verify the new fingerprint through a known channel and update only the authorized address-and-port entry, with host checking still enabled. The restore sequence gives both paths and keeps those decisions before reopening.
Afterward, routine checks confirm expected history, content and current access. The owner must account for writes made after the chosen backup. A successful restore cannot recover work that the snapshot never contained, and it should not overwrite a newer independent copy merely to make the rollback look complete.
Compare the replacement before retiring the old host
A mirror export provides the Git objects and refs for a move. It does not transfer SSH access, service configuration, hooks or external data such as Git LFS content. A mirror push can overwrite or delete destination refs, so this procedure uses only an explicitly authorized empty target. Keep the source available while a fresh clone, ref comparison and access checks establish the replacement. Mirror clone, mirror push, backup limits
Retiring access is a separate decision from destroying retained data. The guide closes activity, disables the account, secures the retained trees and keeps the account's numeric identity reserved while ownership remains unresolved. It also checks for other files on relevant filesystems. Deleting an account name alone can leave files owned by an ID that is later reused. Account removal
Before you build, name the maintainer and the person who will recover the repository. Read the complete operating reference with them, including its migration and retirement steps. If that work has an owner and equal access fits the team, this is a manageable design to assess. If it does not, a hosted private repository can still meet the need for a shared, portable code history.
Keep the guide with your own notes.
Download the complete Markdown version