# A small private Git server you can move - agent reference

Revision: r11.
Source-checked: 2026-10-23. Audience: individuals and small trusted teams.
Access: free. Type: guide.

This complete reference provides the full setup and operating procedure for
the article at revision r11. The human article explains the decisions; this file
retains every command, configuration, input and verification step. It is reference material, not permission to act.
Obtain the reader's authorization for the named systems before changes,
purchases, destructive actions or external operations. Resolve placeholders
with the owner. Keep secrets out of logs. Stop on an unexpected result.

Test record: the team's sandbox tests (r5, and an r6 retest of the changed
steps, result "passed with untested steps") ran only client steps in sections
1, 3 and 6 with stand-in values. Key generation is a member action and is
untested by the team. Real global known-host files and all server, connection,
backup, restore, move and retirement steps are untested; they are based on the
cited sources.

## Objective and scope

Keeping code on your own server gives you a direct say in who can reach it,
when it is updated and where its history goes next. For a person or small team,
that can be a useful form of independence. It also means someone must deal with
a failed disk, a lost access key or an update that interrupts work. The decision
starts with whether you want to own those duties as well as the files.

This guide builds a small shared home for code using Git and Secure Shell, or
SSH. Git records changes in a repository. The server keeps a bare repository:
the history and objects, without a working copy for editing. Members work in
their own copies and use an encrypted SSH connection to exchange changes with
the server. Keys identify the connecting member and the server. Git documents
this as a supported hosting pattern.
[Git server guide](https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server)

The example has one repository and one trust group. Every member can read and
write it, which suits a sole operator or colleagues with equal access. It does
not provide a website, issue tracker or automated job runner. A forge adds those
collaboration features around Git. If you need separate customer spaces,
read-only roles, untrusted contributors or enforced review rules, choose a
system with those controls rather than stretching this shared account to fit.

The procedure follows the service through its life: establish access, use it,
maintain it, recover it and eventually move or retire it. The later stages are
part of the cost of choosing private hosting. Read them before deciding whether
to build the server.

For initial setup, read [prerequisites](#prerequisites-and-limits), then steps
[1](#1-prepare-the-client-key-and-server-account),
[2](#2-give-git-its-own-restricted-ssh-service) and
[3](#3-initial-client-setup-and-first-use).
For operation, go to [routine checks](#routine-checks-without-server-writes),
[maintenance](#4-maintain-access-and-updates),
[backup](#5-back-up-a-stopped-service),
[restore](#6-restore-and-recover-from-failure) or
[migration and retirement](#7-move-to-a-new-host-or-retire-this-one).

## Decide what you want to control

The useful control is concrete: you choose the account, access keys, backup
schedule and next host for the repository. That control still depends on the
operating system, its package sources, the administrator and each member's
computer. If you rent the machine, the infrastructure supplier remains part of
that trust relationship.

It also helps to distinguish a private connection from private storage. SSH
protects the transfer; it does not encrypt repository files on the server's
active disk. A stolen member key, a copied repository or a hostile administrator
can defeat the intended privacy. Even after you have closed a person's access,
you cannot retrieve copies they already downloaded.

Hosted private repositories remain a reasonable choice when nobody can maintain
a server. GitHub's terms treat private repository content as confidential, with
stated access exceptions. Those terms do not support a blanket claim that private
hosting means model training. Optional AI features have separate terms and controls.
[GitHub terms, sections E and J](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service)

For example, GitHub's current Copilot policy permits training use of individual
plan interaction data from 24 April 2026, with an opt-out. It states a different
rule for Business and Enterprise data. Check your actual AI plan and settings;
a repository hosting plan is a different choice. A local repository does not
stop an editor extension from sending code to an external AI service.
[Copilot policy](https://docs.github.com/en/copilot/how-tos/manage-your-account/manage-policies)

The practical comparison includes more than the monthly host bill. Budget for
independent backup storage, network access and the time of a named maintainer.
A small component set can reduce what you maintain, but it does not promise
lower cost or better security than a hosted service.
No price or capacity measurement was made for this guide. If nobody can take
responsibility for recovery and updates, a hosted private repository may be the
more useful choice.

## Prerequisites and limits

The instructions below come from documentation, not a setup run by this team.
The expected results tell you what to check on your own system. The team has not
performed the access, backup, restore or migration procedures. Keep that limit
in mind when deciding how to introduce the service into real work.

Use a dedicated Debian 13 (trixie) amd64 server with systemd, a local filesystem
and a separate administrator account with sudo. Use a Linux client with Bash,
Git and OpenSSH. Start with a new server account named `git`; stop if it already
exists or if the paths below contain data. Do not apply the guide to a forge
server or a shared production SSH configuration.

The commands assume that networking, storage and recovery access already exist.
They do not arrange those services for you. Before setup, confirm each of these
requirements:

- An existing private network connection to approved clients. Its network rules
  must permit TCP 2222 only from those clients and deny public access. This guide
  does not create a VPN or change a router. A private IP address alone is not an
  access control. Keep administrative SSH access under its own rules.
- A known private IPv4 address. No public DNS, web port or TLS certificate is
  required. The Git SSH service will bind only that address, not IPv6.
- Enough free space for history, incoming pushes and temporary Git work. Reserve
  at least another repository-sized amount of working space as a planning
  allowance, then measure actual use. This is not a capacity guarantee.
- A separate, encrypted backup volume with a tested mount procedure and recovery
  key kept away from this host. Its example mount point is `/mnt/git-backup`.
  Confirm that it is independent storage, not a directory on the server disk.
- Console recovery access, a named maintainer, and an agreed maintenance window.

The Debian package pages checked on 23 October list Git `1:2.47.3-0+deb13u1` and
OpenSSH server `1:10.0p1-7+deb13u4`. These are source snapshots, not tested pins.
Use the current security-supported trixie packages from configured official
Debian sources. Record the exact versions installed. Do not hold an older package
solely to match this text. A different release needs a fresh configuration review.
[Git package](https://packages.debian.org/trixie/git),
[OpenSSH package](https://packages.debian.org/trixie/openssh-server)

Read the commands as a sequence of decisions, not a script to paste and rerun.
Run one step at a time and stop on an unexpected result. Account creation, key
generation, file initialization and clone destinations must use new names or
paths. In particular, the command that creates an empty access file would erase
an existing member list if repeated.

Uppercase names are values you must supply. Replace
`PRIVATE_IPV4` with the server address. `PUBLIC_KEY_BASE64` is the public part of
a reader-generated key. `MEMBER_LABEL` identifies its owner. `BACKUP_DATE` names
one new backup directory name, such as `2026-10-23-before-update`; use only
letters, digits and hyphens. `NEW_PRIVATE_IPV4` is the replacement server address.
`CHECK_DIR` is a new private client directory for checks. `KNOWN_PATH` is an
existing repository file whose expected content the owner knows.
`REVOKED_KEY_PATH` is the absolute path to an available revoked test key on its
holder's client. `MOUNT_ROOT` is an approved persistent filesystem mount point.
Private keys, key passphrases and backup recovery keys are secrets. Never put
those secrets in this article, a repository or a public support message.

## 1. Prepare the client key and server account

Each person gets a separate key, although everyone connects to the same Git
account. This lets the administrator identify and remove a member's access
without replacing every other member's key. The server account has a narrower
job: store the shared repository and accept Git operations.

On each member's client, create a separate key. The member runs the
`ssh-keygen -t` command in their own terminal and types a strong passphrase at
its prompt. An agent must not receive, choose or pass the passphrase: do not
use `-N` or an empty passphrase. An agent stops at that command and asks the
member to run it, even if it has a terminal. If either named key file already
exists, the `test` check ends that line without a new key. Then stop and ask
the member; do not overwrite an existing key.
Send only the `.pub` file to the administrator through an authenticated channel.
Compare its fingerprint with the administrator through a second known channel.
[ssh-keygen manual](https://manpages.debian.org/trixie/openssh-client/ssh-keygen.1.en.html)

```bash
umask 077
mkdir -p ~/.ssh
chmod 700 ~/.ssh
test ! -e ~/.ssh/ss_git_ed25519 && test ! -e ~/.ssh/ss_git_ed25519.pub &&
ssh-keygen -t ed25519 -f ~/.ssh/ss_git_ed25519 -C 'private-git-member'
ssh-keygen -lf ~/.ssh/ss_git_ed25519.pub
```

The `ssh-keygen -lf` line after `ssh-keygen -t` is also the member's step. An
agent that stopped at `ssh-keygen -t` does not run it. If the `test` line
stopped because a key file exists, the fingerprint that the last line prints
belongs to that existing key, not to a new one.

On the server, from the administrator's home directory:

```bash
umask 077
sudo apt-get update
apt-cache policy git openssh-server
sudo apt-get install git openssh-server
sudo adduser --system --group --home /var/lib/private-git \
  --shell /usr/bin/git-shell git
sudo chown root:root /var/lib/private-git
sudo chmod 755 /var/lib/private-git
sudo install -d -o root -g root -m 755 /srv/git
sudo install -d -o git -g git -m 700 /srv/git/project.git
sudo -u git git init --bare --initial-branch=main /srv/git/project.git
sudo -u git git --git-dir=/srv/git/project.git config receive.denyNonFastForwards true
sudo -u git git --git-dir=/srv/git/project.git config receive.denyDeletes true
sudo -u git git --git-dir=/srv/git/project.git config receive.fsckObjects true
```

Expected: a new bare repository with `main` as its initial branch name.
A ref is a name that points to a Git object. Branch refs start with `refs/heads/`.
In the cited Git implementation, `denyNonFastForwards` prevents replacement of
a branch's existing line of history, and `denyDeletes` prevents branch deletion.
These two checks do not provide tag immutability. `receive.fsckObjects` checks
received objects for integrity; none of these settings reviews code.
[git-init](https://git-scm.com/docs/git-init),
[Git v2.47.3 receive implementation](https://raw.githubusercontent.com/git/git/v2.47.3/builtin/receive-pack.c),
[git-config](https://git-scm.com/docs/git-config)

The account uses `git-shell`, which allows Git server commands. Do not create
`git-shell-commands` under its home. That directory can enable extra commands.
The home is root-owned to keep members from adding it. This shell is not a
filesystem sandbox: any repository the account can read can be a target. Keep
this account dedicated and do not give it access to unrelated repositories.
[git-shell](https://git-scm.com/docs/git-shell),
[Debian adduser](https://manpages.debian.org/trixie/adduser/adduser.8.en.html)

## 2. Give Git its own restricted SSH service

Recovery is easier to manage when stopping Git does not also remove your way
into the server. This design therefore gives Git its own SSH service and host
identity, separate from administrative SSH. Its listener will accept connections
only on the private address and port chosen for Git.

On the server, create that identity once:

```bash
sudo ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_git_ed25519_key
sudo ssh-keygen -lf /etc/ssh/ssh_host_git_ed25519_key.pub
sudo install -o root -g root -m 644 /dev/null /etc/ssh/git-authorized-keys
sudoedit /etc/ssh/git-authorized-keys
```

The host private key has no passphrase so the service can start unattended.
Keep it readable only by root. In `git-authorized-keys`, add one complete line
per approved member. Keep the `restrict` prefix. The file holds public keys;
root owns it and the Git account must be able to read it.

```text
restrict ssh-ed25519 PUBLIC_KEY_BASE64 MEMBER_LABEL
```

Create `/etc/ssh/sshd_config_git` with `sudoedit`. Replace `PRIVATE_IPV4` before
validation. Use this complete file; do not add an `Include` of the main SSH file.

```text
Port 2222
AddressFamily inet
ListenAddress PRIVATE_IPV4
HostKey /etc/ssh/ssh_host_git_ed25519_key
PidFile /run/sshd-git.pid
AllowUsers git
PubkeyAuthentication yes
AuthenticationMethods publickey
AuthorizedKeysFile /etc/ssh/git-authorized-keys
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitEmptyPasswords no
PermitRootLogin no
UsePAM yes
StrictModes yes
DisableForwarding yes
PermitTTY no
PermitUserRC no
PermitUserEnvironment no
PermitTunnel no
X11Forwarding no
LogLevel VERBOSE
```

These settings require a public key and disable forwarding, terminals and user
startup files. `UsePAM yes` retains Debian's account and session checks; it does
not enable password access here. If account checks deny a login, inspect the
reason. Do not enable passwords or replace `git-shell` to make a test pass.
[Debian sshd_config](https://manpages.debian.org/trixie/openssh-server/sshd_config.5.en.html),
[authorized-key restrictions](https://manpages.debian.org/trixie/openssh-server/sshd.8.en.html)

Create `/etc/systemd/system/sshd-git.service` with `sudoedit`:

```ini
[Unit]
Description=Private Git SSH service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStartPre=/usr/bin/install -d -o root -g root -m 0755 /run/sshd
ExecStartPre=/usr/sbin/sshd -t -f /etc/ssh/sshd_config_git
ExecStart=/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config_git
KillMode=control-group
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
```

`KillMode=control-group` ends processes that remain in this unit when it stops.
PAM can register login sessions in separate scopes. Use Stop Git and check
sessions in step 4 before treating all dedicated-account activity as closed.
Schedule stops: an active Git transfer can be interrupted.

A private network interface must be ready before startup. If it is not, fix the network
service ordering; never change the listener to a public wildcard to get past it.
[systemd process control](https://manpages.debian.org/trixie/systemd/systemd.kill.5.en.html),
[PAM session scopes](https://manpages.debian.org/trixie/libpam-systemd/pam_systemd.8.en.html),
[Debian service units](https://manpages.debian.org/trixie/systemd/systemd.service.5.en.html)

Check and start the Git service:

```bash
sudo chmod 644 /etc/ssh/sshd_config_git /etc/systemd/system/sshd-git.service
sudo install -d -o root -g root -m 755 /run/sshd
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git
sudo /usr/sbin/sshd -T -f /etc/ssh/sshd_config_git
sudo systemctl daemon-reload
sudo systemctl enable --now sshd-git.service
sudo systemctl status sshd-git.service --no-pager
sudo ss -ltnp
```

Expected: syntax validation exits with zero; effective settings match the file;
`sshd-git.service` is active; TCP 2222 listens only on your chosen private IPv4.
There must be no Git listener on a public address or IPv6. Other listeners,
including administrative SSH, need their own access policy. Stop on any mismatch.
The `-t` and `-T` options check syntax and effective configuration; they do not
prove that remote access controls work.
[sshd options](https://manpages.debian.org/trixie/openssh-server/sshd.8.en.html)

## 3. Initial client setup and first use

Before sending code, establish which server the client is talking to. Then make
one initial commit in the new sample repository. Those are different jobs:
a later recovery check must confirm the saved history without adding sample
content to it. The routine check section below provides that separate route.

### Client identity setup

Obtain the Git host key fingerprint from the administrator's console through a
known channel. On the client, put this entry near the start of `~/.ssh/config`,
before general defaults and matching includes. Replace the address. Do not
create a duplicate `Host private-git` entry. Most SSH options use their first
obtained value. [SSH client configuration](https://manpages.debian.org/trixie/openssh-client/ssh_config.5.en.html)

```text
Host private-git
    HostName PRIVATE_IPV4
    Port 2222
    User git
    IdentityFile ~/.ssh/ss_git_ed25519
    IdentitiesOnly yes
    StrictHostKeyChecking ask
    UserKnownHostsFile ~/.ssh/known_hosts
    UpdateHostKeys no
    ForwardAgent no
    ControlMaster no
    ControlPath none
```

Client, before connecting:

```bash
ssh -G private-git
```

Check the effective hostname, port 2222, user `git`, identity file,
`identitiesonly yes`, host-key policy, known-host file, `updatehostkeys false`,
`forwardagent no` and `controlmaster false` (or `no`). The output has no
`controlpath` line: `ssh -G` does not print `ControlPath none`, so the absent
line means `none`. A `controlpath` line with a path is unexpected. Check for
extra identity files, forwarding rules or a `HostKeyAlias` from other
configuration. `UpdateHostKeys no` keeps SSH from adding host keys that the
server sends after login; this entry otherwise counts as the default
known-host file, for which OpenSSH enables those updates. Resolve
unexpected settings before connecting; this guide uses the literal IPv4 address
and its port as the known-host name. `ssh -G` displays settings, not a connection
test. [ssh manual](https://manpages.debian.org/trixie/openssh-client/ssh.1.en.html),
[UpdateHostKeys and ControlPath](https://manpages.debian.org/trixie/openssh-client/ssh_config.5.en.html)

Run `ssh -T private-git`. Compare the first host prompt's fingerprint with the
trusted record before accepting it. A mismatch is a stop condition. After it
matches, change `StrictHostKeyChecking ask` to `StrictHostKeyChecking yes` and
check `ssh -G private-git` again. Authentication can succeed while interactive
access fails with a Git-shell message; that shell refusal is expected.

### First-use writes: new sample repository only

Use this block only once, on the new empty repository from step 1, with the
owner's permission. Do not use it after an update, restore or migration.
Client, in a new empty working directory:

```bash
git clone private-git:/srv/git/project.git project && cd project
```

Stop if the clone or directory change fails. Then:

```bash
git config user.name 'Example Member' &&
git config user.email 'member@example.invalid' &&
printf '%s\n' '# Private project' > README.md &&
git add README.md &&
git commit -m 'Start private project' &&
git push -u origin main
```

Replace the example commit identity with the chosen name and email address.
They become history visible to members. The initial empty-repository warning is
expected; the push must create `main`. Stop on an error. The checks below do not
repeat this content creation. [git-clone](https://git-scm.com/docs/git-clone),
[git-push](https://git-scm.com/docs/git-push)

### Optional branch-deletion check: authorized writes

This check changes only a new disposable branch in the sample repository. Obtain
explicit permission to create, attempt to delete, and retain
`refs/heads/ss-deny-delete-check-r2`. Never substitute `main` or a production tag.
Client, from the sample `project` clone, first check that the name is absent:

```bash
git ls-remote --exit-code --heads origin refs/heads/ss-deny-delete-check-r2
```

Expected: no matching ref and exit status 2. Status 0 means it already exists;
stop and do not reuse it. Authentication or transport errors are not absence.
Then create the branch at the existing sample commit and push that exact ref:

```bash
git branch ss-deny-delete-check-r2 HEAD &&
git push origin refs/heads/ss-deny-delete-check-r2:refs/heads/ss-deny-delete-check-r2 &&
git ls-remote --exit-code --heads origin refs/heads/ss-deny-delete-check-r2
```

Record the returned object ID. Only after a successful push and ref read, attempt
the authorized deletion:

```bash
git push origin :refs/heads/ss-deny-delete-check-r2
```

Expected: the server reports deletion prohibited and the push fails. A timeout,
host-key error or login failure does not test branch protection. Read it again:

```bash
git ls-remote --exit-code --heads origin refs/heads/ss-deny-delete-check-r2
```

Expected: the same full branch name and object ID, exit zero. If it is missing or
changed, stop and review the server settings. Retain this harmless sample branch
as the agreed check marker. No cleanup command weakens server protections; any
later administrative removal needs its own reviewed decision. Do not repeat
this write check against production during recovery.
[git-ls-remote](https://git-scm.com/docs/git-ls-remote),
[branch guards](https://raw.githubusercontent.com/git/git/v2.47.3/builtin/receive-pack.c)

### Routine checks without server writes

Use this section after setup, updates, restore and migration. It reads the server;
it creates only new local check files. Keep member writes frozen during comparison.
Do not run the first-use or branch-creation blocks. The service may be open for
these checks only after the administrator has completed the identity and access
decisions in step 6 when recovery is involved.

For migration checks, substitute `replacement-git` for the `private-git` alias
below and use the replacement address in direct SSH URLs.

Server administrator: confirm the intended hostname/address, repository path,
current approved-key list and current revocation record. Read the host fingerprint
from the console. Check the listener and repository:

```bash
sudo ssh-keygen -lf /etc/ssh/ssh_host_git_ed25519_key.pub
sudo ss -ltnp
sudo -u git git --git-dir=/srv/git/project.git fsck --full
sudo -u git git --git-dir=/srv/git/project.git symbolic-ref HEAD
sudo -u git git --git-dir=/srv/git/project.git for-each-ref --format='%(objectname) %(refname)'
```

Expected: the intended private listener only, no missing/corrupt objects,
`refs/heads/main` as HEAD, and the owner-approved refs. Keep an independently
retained expected ref list: for maintenance use the accepted pre-update snapshot;
for restore use the chosen backup's `project.refs`; for migration use `source.refs`.
For first setup, record the approved server ref output through the administrator.
Do not make a changed server its own only reference for a recovery comparison.

Client: create a new private check directory; stop if creation fails:

```bash
mkdir -m 700 CHECK_DIR && cd CHECK_DIR
```

Obtain the expected list through the administrator's known channel and save its
exact lines as `expected.refs` with a local text editor in this directory.
Confirm its snapshot and source. A restored old snapshot can legitimately omit
later writes; record that loss before accepting it. Check `ssh -G private-git`
against the intended current target and the approved host-key record. Then, from
`CHECK_DIR`:

```bash
umask 077
git clone --mirror private-git:/srv/git/project.git verification.git &&
git -C verification.git fsck --full &&
git -C verification.git symbolic-ref HEAD &&
git -C verification.git for-each-ref --format='%(objectname) %(refname)' > actual.refs &&
diff -u expected.refs actual.refs
```

Expected: HEAD names `refs/heads/main`; diff has no output and exits zero.
Stop on any clone, integrity or ref error. Read expected history and a known file:

```bash
git -C verification.git log --oneline --max-count=5 refs/heads/main
git -C verification.git show 'refs/heads/main:KNOWN_PATH'
```

Compare these with the owner's expected commits and content. Replace `KNOWN_PATH`
with an existing file path relative to the repository root. A mirror clone keeps
refs without adding sample commits. [git-clone](https://git-scm.com/docs/git-clone),
[ref listing](https://git-scm.com/docs/git-for-each-ref),
[integrity check limits](https://git-scm.com/docs/git-fsck),
[history](https://git-scm.com/docs/git-log) and
[file content](https://git-scm.com/docs/git-show)

Confirm that the current approved key can read. For a removed key, its authorized
holder uses that key on their own client; do not collect their private key.
Client, replace `REVOKED_KEY_PATH` and the current server `PRIVATE_IPV4`:

```bash
git -c core.sshCommand='ssh -F /dev/null -o IdentityAgent=none -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=~/.ssh/known_hosts -i "REVOKED_KEY_PATH"' ls-remote ssh://git@PRIVATE_IPV4:2222/srv/git/project.git
```

Expected: public-key authentication is denied, with no repository refs returned.
The command excludes agent and configuration fallback identities. Check the
specified private key is present and readable: a missing key, network failure or
host-key mismatch is not a revocation pass. If no removed test key is available,
record that limit and reconcile the access list; do not invent a successful test.
Use the same isolated-key check with a known unlisted key when available.

On endpoints you own, also check these read-only access outcomes:

- `ssh private-git id` fails; the Git account does not provide a general shell.
- `ssh -N -o ExitOnForwardFailure=yes -R 0:127.0.0.1:22 private-git` reports
  forwarding denied. End an unexpected open connection and correct the settings.
- From an authorized check host outside the allowed network, TCP 2222 is not
  reachable on any assigned server address. A timeout alone does not test keys.

Do not disable host-key checking to clear an error. Review
`sudo journalctl -u sshd-git.service --since today` on the server. Logs and local
clones contain private information; retain them with restricted access. Record
actual results and limits. These checks do not prove that code itself is safe.

## 4. Maintain access and updates

Once the repository is in use, changes in people and devices matter as much as
software updates. Removing a key from the access list affects new logins. An
already open connection needs a separate closure check. This distinction also
matters when you need a quiet repository for backup or retirement.

Record each public key fingerprint, owner and removal date in a restricted
administrator record outside the Git account and outside the restorable server
snapshot. Keep separate retained off-host copies of this current record. It must
survive loss of the original host without rolling revocations back to snapshot time.

To remove a member, delete that key's whole line with
`sudoedit /etc/ssh/git-authorized-keys`. This affects new logins. For urgent
revocation, complete [Stop Git and check sessions](#stop-git-and-check-sessions)
below. Recheck the current access list while closed. Only after its checks pass,
validate the configuration and start for the routine read-only access checks:

```bash
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git &&
sudo systemctl start sshd-git.service
```

Confirm current approved/revoked-key outcomes with Routine checks without server
writes. On any unexpected result, stop and investigate; do not end the write freeze.

### Stop Git and check sessions

A stopped listener prevents new connections through that listener, but it is
only one part of closing existing activity. The following procedure checks the
service, registered login sessions, processes and network connections in turn.
Use the complete sequence for urgent revocation, backup and retirement, from the
separate administrator account with console recovery available. Obtain
the owner's permission to interrupt all activity of the dedicated `git` account;
this includes any registered sessions outside the custom unit. Keep member writes
frozen. Do not terminate the administrator's account, kill all `sshd` processes,
or disable PAM. These are proposed reader checks; the team has not run them.

Server, first identify the dedicated account and stop its listener:

```bash
id git &&
sudo systemctl stop sshd-git.service &&
sudo systemctl show sshd-git.service -p ActiveState -p MainPID -p ControlGroup
```

Require `ActiveState=inactive` and `MainPID=0`. Record the unit's control-group
path if shown. A stop error or another state is a stop condition, not successful
closure. A unit stop does not by itself establish that every login session ended.

Server, inspect registered users and sessions:

```bash
sudo loginctl --no-pager list-users &&
sudo loginctl --no-pager list-sessions
```

Both commands must succeed. Match the exact `git` name and numeric UID from `id`,
not the administrator's row. If Git is listed, inspect its status and record its
session IDs, session scope paths and relevant process IDs before termination:

```bash
sudo loginctl --no-pager user-status git
```

Under the interruption permission above, terminate only this dedicated user's
registered activity:

```bash
sudo loginctl terminate-user git
```

If both successful lists show no Git user or session, skip these two commands.
A failed lookup, missing login manager or permission error does not mean absence.
A session that disappears between commands needs a new inspection; do not treat
an error as proof. After termination, repeat both list commands and require no
Git session. If Git still has a registered user entry, inspect and resolve it
before continuing. This guide does not require termination of other users.
[Login session controls](https://manpages.debian.org/trixie/systemd/loginctl.1.en.html)

Server, check processes with the dedicated effective UID:

```bash
pgrep -a -u git
printf 'pgrep exit status: %s\n' "$?"
```

Exactly status 1 means no matches. Status 0 means processes remain. With the same
owner permission, use `sudo pkill -TERM -u git` for those dedicated-account
processes, then repeat the check. A signal request is not proof of exit. Any
other status or process that remains needs investigation while Git stays stopped.
These commands select effective UID; they are not the whole session inventory.
[Process selection and return status](https://manpages.debian.org/trixie/procps/pgrep.1.en.html)

Server, inspect the remaining process tree context and TCP sockets:

```bash
sudo ps -e -ww -o pid,ppid,euid,egid,cgroup,args &&
sudo ss -H -tanp '( sport = :2222 )' &&
sudo systemctl show sshd-git.service -p ActiveState -p MainPID -p ControlGroup
```

Each command must succeed. Compare processes with the recorded Git unit/session
scope paths and parent/child relationships. Check for remaining Git work and
privileged SSH processes tied to this endpoint, not just processes with Git's
UID. Keep private process arguments and connection records restricted. An unclear
process relationship requires investigation, not a broad kill command.

Require no remaining relevant service/session process, an inactive unit and no
TCP rows for local port 2222. A closing or TIME-WAIT row can outlast a client;
wait for it to clear and repeat the check instead of calling it an active login
or ignoring it. Inspect the full port on this dedicated host so a different
local address cannot hide a surviving connection. Tool errors or unresolved
process/socket state keep the service closed. Do not proceed to backup or
retained-data changes until these checks pass.
[Process fields](https://manpages.debian.org/trixie/procps/ps.1.en.html),
[socket states and filters](https://manpages.debian.org/trixie/iproute2/ss.8.en.html)

Where an authorized test connection was already open before the stop, ask its
holder to confirm that this same connection closed. Record an unavailable test
connection as a limit; do not create a write merely to test closure. After the
owner accepts the stopped checks, reopening still follows the relevant procedure.
A fresh login using a revoked key must fail after reopening, but that result is
separate from closure of an older connection. Client sharing settings alone do
not prove what another client's connection did.

### Routine maintenance

Review security notices and failed backup reports each working day. Review access
when a member or device changes. Check free space and logs weekly. Schedule
recovery checks at an interval that matches the data's value. These are suggested
duties, not measured service levels.

For updates, agree a maintenance window and freeze member writes. Complete step 5
and accept the backup while the Git service stays stopped. Do not use the backup's
reopening option. Keep copies of configuration and the current revocation record
outside the host. Server administrator, after backup acceptance:

```bash
sudo apt-get update &&
sudo apt-get upgrade &&
dpkg-query -W git openssh-server openssh-client systemd tar &&
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git
```

Stop on an error. Review packages kept back, package prompts and required security
updates before proceeding. Updates can restart administrative SSH or require a
reboot; keep console recovery available. Confirm Git remains stopped. If a reboot
is needed before checks finish, disable `sshd-git.service` first so boot does not
reopen it. Recheck syntax, effective settings, identity and current access records
when the host returns. Repeat Stop Git and check sessions after a reboot or any
unexpected service activity. Do not silently undo a revocation or trust a changed key.

Once these decisions pass, start Git for the read-only checks, keeping the member
write freeze. Server:

```bash
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git &&
sudo systemctl start sshd-git.service
```

Run Routine checks without server writes against the accepted snapshot. On any
unexpected result, stop the service and investigate. Only after the owner accepts
the checks, enable normal boot startup with `sudo systemctl enable sshd-git.service`
and end the member write freeze. Do not return to the sample README or branch test.

If installation is interrupted, keep Git stopped. Use the console to inspect
`sudo dpkg --audit`, then complete configuration with `sudo dpkg --configure -a`
and resolve any reported package errors. Repeat the stopped checks before startup.
Do not downgrade to a known unsafe build. If data recovery is needed, use step 6
on a separate target and account for all later writes.
[apt-get](https://manpages.debian.org/trixie/apt/apt-get.8.en.html),
[dpkg](https://manpages.debian.org/trixie/dpkg/dpkg.1.en.html)

## 5. Back up a stopped service

A useful recovery copy needs more than the latest source files. It needs the
repository's history and the settings that govern access. Stopping activity
before copying them gives this small design a clear point to preserve. The
tradeoff is a planned interruption for members, followed by checks before work
resumes.

The archive covers this exact layout: history, configuration, public access keys
and the private SSH host key. `tar` does not encrypt it. Use the existing encrypted,
independent, root-restricted backup volume. Keep a separate recovery key and an
offline or deletion-protected copy. Confirm through your storage procedure that
`/mnt/git-backup` is that volume; a mount check alone does not establish encryption.

Agree a write freeze and wait for transfers to finish. Complete Stop Git and
check sessions in step 4 and record its accepted result immediately before this
backup. Do not open the listener or allow other Git activity between these steps.
The block below asks for confirmation of that full review; its UID check alone
is not a substitute. Replace `BACKUP_DATE` with
a new directory name. Never reuse a failed or existing backup directory. Server
administrator: run this complete Bash block. Parentheses keep an error exit inside
the block. The service remains stopped on success and failure.

```bash
(
    umask 077
    sudo systemctl stop sshd-git.service || exit 1
    git_service_state=$(sudo systemctl show -p ActiveState --value sshd-git.service) || exit 1
    test "$git_service_state" = inactive || exit 1
    id git >/dev/null || exit 1
    pgrep -a -u git
    git_process_status=$?
    test "$git_process_status" -eq 1 || exit 1
    read -r -p 'Full stopped-session/process/socket review accepted? Type CLOSED: ' git_stop_review || exit 1
    test "$git_stop_review" = CLOSED || exit 1
    findmnt --mountpoint /mnt/git-backup || exit 1
    if sudo -u git git --git-dir=/srv/git/project.git fsck --full &&
       sudo mkdir -m 700 /mnt/git-backup/BACKUP_DATE &&
       sudo sh -c 'umask 077; dpkg-query -W git openssh-server openssh-client systemd tar > /srv/git/package-versions.txt' &&
       sudo sh -c 'umask 077; git -c safe.directory=/srv/git/project.git --git-dir=/srv/git/project.git for-each-ref --format="%(objectname) %(refname)" > /srv/git/project.refs' &&
       sudo chmod 600 /srv/git/package-versions.txt /srv/git/project.refs &&
       sudo tar -C / -cpf /mnt/git-backup/BACKUP_DATE/private-git.tar \
         srv/git var/lib/private-git etc/ssh/git-authorized-keys \
         etc/ssh/sshd_config_git etc/ssh/ssh_host_git_ed25519_key \
         etc/ssh/ssh_host_git_ed25519_key.pub etc/systemd/system/sshd-git.service &&
       sudo chmod 600 /mnt/git-backup/BACKUP_DATE/private-git.tar &&
       sudo tar -tf /mnt/git-backup/BACKUP_DATE/private-git.tar &&
       sudo sh -c 'cd /mnt/git-backup/BACKUP_DATE && sha256sum private-git.tar > SHA256SUMS && sha256sum -c SHA256SUMS'
    then
        printf '%s\n' 'Archive checks finished. Keep Git stopped for manual review.'
    else
        printf '%s\n' 'Backup failed. Keep Git stopped; do not use this directory as a valid backup.' >&2
        exit 1
    fi
)
```

`ActiveState=inactive` is checked directly rather than treating every nonzero
`is-active` result as success. `pgrep` must return exactly 1 for no processes;
0 or an error stops the block. A failed object check stops before directory
creation. Missing stopped-state acceptance stops before any backup write.
An existing directory makes `mkdir` fail, so no archive write follows.
An archive or checksum failure prevents the success message. Keep any incomplete
new directory marked invalid; preserve previous copies and choose a fresh name
for a retry. Never append restart to this block.
[Bash conditional lists](https://manpages.debian.org/trixie/bash/bash.1.en.html),
[systemctl](https://manpages.debian.org/trixie/systemd/systemctl.1.en.html),
[pgrep statuses](https://manpages.debian.org/trixie/procps/pgrep.1.en.html),
[tar](https://manpages.debian.org/trixie/tar/tar.1.en.html)

After a zero exit, inspect the archive list and checksum result. Confirm the
intended snapshot and retained files; record its time, location and ref list
outside the host. A successful checksum does not prove authenticity if both files
can be replaced, and a valid archive is not proof of a successful restore.

If this is a pre-update backup, stay stopped and continue step 4. For a standalone
backup only, the owner may authorize reopening after accepting these checks.
If backup failed, first record the explicit decision to reopen with the known
backup gap; otherwise remain stopped. That decision cannot waive unresolved
session, process, socket, identity or access checks. Repeat Stop Git and check
sessions if its result is uncertain before any reopening. Server, only after
that separate decision:

```bash
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git &&
sudo systemctl start sshd-git.service
```

Check service status and run the routine read-only checks before ending the write
freeze. Safely detach the backup volume after all writes finish. A daily schedule
can lose writes since the last valid copy. Let the owner set retention and the
acceptable loss window. No recovery time is measured here.

## 6. Restore and recover from failure

Recovery has two questions: whether the saved data is the right data, and whether
the restored service has an identity and access list you can still trust. A
backup can predate a member's removal or contain a host key that was later
exposed. Keep the replacement stopped while you resolve both questions. Copying
files successfully is not permission to reconnect clients.

### Stopped target and data checks

Use a new, isolated Debian server with console access and the old endpoint stopped.
If compromise is suspected, also isolate the old host from the network. Follow only step 1's package installation, account creation and
root-owned home setup; do not initialize `project.git`, create access files, or
start the Git service. Do not run step 2's initial key generation/startup block.
Use the same supported package family. Keep this target stopped through all
identity and access decisions below, including any reboot.

Server administrator, from a private home directory with `umask 077`, attach a
known backup. Replace `BACKUP_DATE`. Check the hash, then the list:

```bash
sudo sh -c 'cd /mnt/git-backup/BACKUP_DATE && sha256sum -c SHA256SUMS' &&
sudo tar -tf /mnt/git-backup/BACKUP_DATE/private-git.tar
```

Expected: checksum OK and only the step 5 paths. Stop on any error or unexpected
entry. Choose another retained backup if needed. Do not extract an untrusted
archive as root. If compromise is suspected, the owner must accept a reviewed,
known-good backup; do not start restored hooks or configuration of unknown origin.
A hook is a server-side program run in response to a Git event.

DESTRUCTIVE: the next block replaces the listed destination files. The owner must
authorize this exact empty target. Confirm its hostname and address. Do not
extract over a running service or unpreserved newer work. Server:

```bash
sudo tar -C / -xpf /mnt/git-backup/BACKUP_DATE/private-git.tar &&
sudo chown -R git:git /srv/git/project.git &&
sudo chown root:root /srv/git /var/lib/private-git /etc/ssh/git-authorized-keys &&
sudo chmod 755 /srv/git /var/lib/private-git &&
sudo chmod 644 /etc/ssh/git-authorized-keys &&
sudo chmod 600 /etc/ssh/ssh_host_git_ed25519_key &&
sudo -u git git --git-dir=/srv/git/project.git fsck --full &&
sudo -u git git --git-dir=/srv/git/project.git for-each-ref --format='%(objectname) %(refname)' > restored-project.refs &&
sudo diff -u /srv/git/project.refs restored-project.refs
```

Expected: no integrity error; ref comparison has no output and exits zero. Stop
on failure. Review restored configuration and hooks before use. Reconcile the
public-key list with the current independently retained revocation record. Remove
all keys revoked after the snapshot. If the record is unavailable, do not reopen
member access until the owner reconstructs and approves the current list.

### Host identity decision before startup

Choose and record one path while the service is stopped:

- **No exposure:** retain the restored host key only if the owner accepts that
  its secret was not exposed. Verify its console fingerprint against the retained
  trusted record. Keep just one active endpoint for that identity.
- **Exposure or uncertainty:** replace the dedicated host key pair before startup.
  DESTRUCTIVE: the owner must authorize loss of that old identity. The old archive may retain
  it as restricted evidence, but it must never be reactivated. Server:

```bash
sudo rm -- /etc/ssh/ssh_host_git_ed25519_key /etc/ssh/ssh_host_git_ed25519_key.pub &&
sudo ssh-keygen -t ed25519 -N '' -f /etc/ssh/ssh_host_git_ed25519_key
```

Any failure leaves the service stopped. Do not restore the exposed identity to
clear it. On either path, set and check the chosen pair's ownership and mode:

```bash
sudo chown root:root /etc/ssh/ssh_host_git_ed25519_key /etc/ssh/ssh_host_git_ed25519_key.pub &&
sudo chmod 600 /etc/ssh/ssh_host_git_ed25519_key &&
sudo chmod 644 /etc/ssh/ssh_host_git_ed25519_key.pub &&
sudo stat -c '%U:%G %a %n' /etc/ssh/ssh_host_git_ed25519_key /etc/ssh/ssh_host_git_ed25519_key.pub &&
sudo ssh-keygen -lf /etc/ssh/ssh_host_git_ed25519_key.pub
```

Expected: `root:root 600` for the private file and `root:root 644` for its public
file. Record the fingerprint from the trusted console. Supply only the public
`.pub` file to each client through an authenticated channel, and confirm its
fingerprint through the independent known channel.
[ssh-keygen](https://manpages.debian.org/trixie/openssh-client/ssh-keygen.1.en.html)

### Client trust transition while the target is stopped

For an unchanged key at the same address, check its existing entry against that
trusted fingerprint; do not remove it. For a new address or an authorized key
replacement, update only the current target's entry. Keep `StrictHostKeyChecking
yes`. A client that has not yet connected, such as a member added during
recovery, still has `ask`; it changes this to `yes` before the final check
below. Change the `HostName` in `~/.ssh/config` to the target's private IPv4 and
check `ssh -G private-git`. The commands below use this address as `PRIVATE_IPV4`
and the explicit port 2222; do not use the alias name as a substitute.

Client: create one new, empty private working directory (mode 700) for this
transition, and run every client command in this section from it. Save the
delivered public key there as `verified-git-host.pub`. Make sure the known-host
file exists, then read the key's fingerprint and inspect the existing target
entry:

```bash
test -e ~/.ssh/known_hosts || install -m 600 /dev/null ~/.ssh/known_hosts
ssh-keygen -lf verified-git-host.pub
ssh-keygen -F '[PRIVATE_IPV4]:2222' -f ~/.ssh/known_hosts
```

The first line creates an empty known-host file with mode 600 only if none
exists. Without a file, `ssh-keygen -F` fails with exit status 255. For `-F`,
exit status 0 with printed lines means an entry exists; exit status 1 with no
output means no entry. Compare the new fingerprint with the independent
console record before editing.
These selected `-F` and `-R` operations also handle hashed known-host entries.
An absent target entry can be normal for a new address. An unexplained mismatch,
an unexpected host alias, or an extra/global trust entry is a stop condition;
resolve it with the administrator. Never remove trust merely because SSH warns.
To check the global trust files, check each file that exists among those named
on the `globalknownhostsfile` line of `ssh -G private-git`. These are the
default names; use the listed names if they differ:

```bash
for f in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2; do
  test ! -e "$f" || ssh-keygen -F '[PRIVATE_IPV4]:2222' -f "$f"
done
```

Expected: no output. Printed lines mean a global entry for this target; stop.

After owner authorization of this exact address, port and new fingerprint,
confirm `known_hosts.before-recovery` does not exist in the transition
directory. Save a private copy of the existing known-host file under this fresh
name, then remove only this target's old entry. If the earlier `-F` check found
no entry, for example on a new client, still make the copy but skip the
removal block. Client, copy:

```bash
test ! -e ./known_hosts.before-recovery &&
cp -p -- ~/.ssh/known_hosts ./known_hosts.before-recovery &&
chmod 600 ./known_hosts.before-recovery
```

Client, removal: run this only if the copy succeeded and the earlier `-F`
check found an entry for this target:

```bash
ssh-keygen -R '[PRIVATE_IPV4]:2222' -f ~/.ssh/known_hosts
```

The new transition directory keeps the saved copy from overwriting an earlier
one. Add exactly one line with the verified Ed25519 public-key
value from `verified-git-host.pub`. The line has only three fields: the host,
the key type and the base64 key. Leave out the comment field of the `.pub`
file. Do not obtain the trusted value from an unverified network scan. The
line has this form:

```text
[PRIVATE_IPV4]:2222 ssh-ed25519 PUBLIC_KEY_BASE64
```

The member or the agent can write it with a text editor, or with this command,
which reads the first two fields of the verified file and stops unless the key
type is `ssh-ed25519`:

```bash
read -r keytype keyb64 _ < verified-git-host.pub &&
test "$keytype" = ssh-ed25519 &&
{ test -z "$(tail -c 1 ~/.ssh/known_hosts)" || echo >> ~/.ssh/known_hosts; } &&
printf '[PRIVATE_IPV4]:2222 %s %s\n' "$keytype" "$keyb64" >> ~/.ssh/known_hosts
```

On a client that still has `StrictHostKeyChecking ask`, change it to
`StrictHostKeyChecking yes` in `~/.ssh/config` now. Then check the saved entry
and effective client settings again:

```bash
chmod 600 ~/.ssh/known_hosts &&
ssh-keygen -F '[PRIVATE_IPV4]:2222' -f ~/.ssh/known_hosts > current-host-entry &&
ssh-keygen -lf current-host-entry &&
ssh -G private-git
```

The target's fingerprint must equal the approved new value, and `ssh -G`
must print `stricthostkeychecking true` (set as `yes`). The current-host-entry
output must contain exactly one key line for this target. A second key line
means an old entry remains; stop and confirm with the owner that it is the
old target entry. The removal block deletes every entry for this target,
including the new line. After it runs, add the verified line again and
repeat this check. `ssh-keygen -R` also leaves `~/.ssh/known_hosts.old`,
which keeps the old key; the member deletes that file after this final check
passes. Leave other hosts' entries unchanged. A saved old trust file is recovery
evidence, not permission to trust an exposed key again. Other clients must make
the same authorized transition before they reconnect.
[Selected known-host removal](https://manpages.debian.org/trixie/openssh-client/ssh-keygen.1.en.html),
[known-host format](https://manpages.debian.org/trixie/openssh-server/sshd.8.en.html)

### Start only the reviewed target

Server: change `ListenAddress` to the target's private address and confirm its
network restrictions. Confirm current access keys, approved host identity and
client trust transition are complete. With the member write freeze still active:

```bash
sudo install -d -o root -g root -m 755 /run/sshd &&
sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config_git &&
sudo /usr/sbin/sshd -T -f /etc/ssh/sshd_config_git
```

Review the effective settings before continuing. Then:

```bash
sudo systemctl daemon-reload &&
sudo systemctl start sshd-git.service
```

Use only Routine checks without server writes. Compare with this backup's
expected refs, history and known file content; check approved and revoked keys.
If any result is unexpected, stop Git and investigate. After owner acceptance,
enable startup and end the write freeze. Record actual recovery time and missing
writes. Never repeat first-use README, commit or branch creation during recovery.

For failed updates, prefer a supported package repair. For data loss, preserve
later work in independent clones and compare histories before choosing the
recovered endpoint. A snapshot does not preserve later pushes. Do not overwrite
the newest copy merely to make a rollback appear successful.

## 7. Move to a new host, or retire this one

Git history gives this service a practical exit route. You can copy the objects
and named references to another host, compare them, and move members only after
the replacement checks pass. Access configuration and any data stored outside
Git need their own transfer. Keep the source available until you have accepted
the replacement; a successful export alone is not the end of the move.

Prepare the new host through steps 1-2, with an empty repository, current member
keys and a separately verified host identity. Add a client SSH entry named
`replacement-git`, using `NEW_PRIVATE_IPV4`. Use only Client identity setup in step 3 for that entry; do not run first-use writes.
Freeze writes on the old repository by agreement while keeping it readable for
the export. On a trusted client, in a new directory with `umask 077`:

DESTRUCTIVE: `push --mirror` can overwrite or delete destination refs. Obtain the
owner's permission for this exact empty target before that command. Do not use
an existing team repository.

```bash
git clone --mirror private-git:/srv/git/project.git project-export.git &&
git -C project-export.git fsck --full &&
git -C project-export.git for-each-ref --format='%(objectname) %(refname)' > source.refs &&
git -C project-export.git push --mirror replacement-git:/srv/git/project.git &&
git clone --mirror replacement-git:/srv/git/project.git target-check.git &&
git -C target-check.git fsck --full &&
git -C target-check.git for-each-ref --format='%(objectname) %(refname)' > target.refs &&
diff -u source.refs target.refs
```

Stop on any push, integrity or ref mismatch. Keep the source available until
Routine checks without server writes succeeds against the replacement, using
`source.refs` as the expected list. Do not use the first-use write blocks.
This guide's protection settings can reject a retry against a nonempty target;
review the difference instead of disabling them automatically.
[Mirror cloning](https://git-scm.com/docs/git-clone),
[mirror push semantics](https://git-scm.com/docs/git-push)

A mirror copies the available Git refs and objects. It does not transfer SSH keys,
permissions, server hooks or service configuration. This setup has no issues, review database or LFS object
store. Git LFS keeps large file contents in separate storage; a submodule points
to another repository. If you add either, inventory and move that external data
separately before accepting the migration.
A clone of a forge also needs separate exports for its other data.
[Repository backup limits](https://docs.github.com/en/repositories/archiving-a-github-repository/backing-up-a-repository)

After acceptance, change each working clone's remote and fetch:

```bash
git remote set-url origin replacement-git:/srv/git/project.git
git fetch origin
```

### Retire service access and retain data

After the owner accepts the replacement and backup, keep the old endpoint closed.
Retiring access and destroying stored data are separate decisions. Files may
still need to be kept, but deleting their account name does not remove them.
An old numeric account ID can later be assigned to another account.

For that reason, this procedure keeps the dedicated account and group reserved
until all retained data has an assigned owner and disposition. Do not run
`deluser` or `delgroup` during retention.
[Debian deluser](https://manpages.debian.org/trixie/adduser/deluser.8.en.html),
[filesystem ownership](https://manpages.debian.org/trixie/manpages/inode.7.en.html)

Server, with permission to interrupt remaining sessions:

```bash
sudo systemctl disable --now sshd-git.service
```

Stop if that fails. Complete Stop Git and check sessions in step 4; keep the
service disabled. Require its registered-session, process and socket checks,
not only an empty effective-UID list. Do not change retained data while any
state is unresolved. Remove this endpoint's network access rule through its
owner's normal process.

Server, keep the account reserved but disable its login shell and expire it:

```bash
sudo usermod --shell /usr/sbin/nologin --expiredate 1970-01-02 git &&
sudo chown -R root:root /srv/git /var/lib/private-git &&
sudo chmod 700 /srv/git /var/lib/private-git &&
sudo stat -c '%U:%G %a %n' /srv/git /var/lib/private-git &&
getent passwd git
```

Expected: the two retained directory roots are `root:root 700`; the account's
shell is `/usr/sbin/nologin`. Keep this service disabled. Do not remove OpenSSH
packages used by administrative access. The retention owner is the administrator,
who must keep backups, logs and configuration containing private material restricted.
[Account changes](https://manpages.debian.org/trixie/passwd/usermod.8.en.html)

Inventory other files before any later account deletion. Server:

```bash
git_retired_uid=$(id -u git) &&
git_retired_gid=$(id -g git) &&
sudo find / -xdev \( -uid "$git_retired_uid" -o -gid "$git_retired_gid" \) -print
```

This covers only the root filesystem. Repeat the following for each separate
persistent mount that could contain this account's files. Replace `MOUNT_ROOT`
with that exact approved mount point; do not scan pseudo-filesystems as data:

```bash
sudo find MOUNT_ROOT -xdev \( -uid "$git_retired_uid" -o -gid "$git_retired_gid" \) -print
```

Review every result and any scan error. Secure each retained item under its named
retention owner and restricted parent directory, including files outside `/srv/git`.
Do not automatically delete or recursively change every search result. Keep the
account/group reserved while any item or mount is unresolved, so its ID is not
abandoned for reuse. Record the inventory, owner and retention end date.
[find ownership predicates](https://manpages.debian.org/trixie/findutils/find.1.en.html)

Final destruction of data, backups, the dedicated SSH key/configuration and unit
file is a separate explicit owner decision. Account deletion may occur only after
all retained ownership is resolved. The shutdown above completes service retirement
without forcing that destructive decision. File deletion alone does not guarantee
erasure from snapshots or storage media.

## Alternatives

The choice becomes clearer once the full service life is visible. Bare Git is
useful when shared history and equal access are enough. A self-managed forge
adds issue tracking, reviews and separate roles, together with application data,
updates and exports to maintain. A hosted private forge transfers much of the
server work to a supplier, while identity, integrations, independent backups and
contract choices remain your responsibility. Choose according to those needs.

Git is licensed under GPL version 2, with qualifications in its source notice.
That does not assign the same licence to your code or every component on the
host. Read component notices when redistributing software.
[Git COPYING](https://raw.githubusercontent.com/git/git/master/COPYING)

All commands are reader procedures. Recheck mutable packages, policies and
security advice before use.
