A lightweight SSH-based Git server built with Charmbracelet's Wish and the git
middleware. This project allows multiple users to interact with Git repositories over SSH, with customizable authentication and automatic commit backup functionality.
-
🧠 Public Key-Based Authorization per Repo
- Each Git repo has its own list of authorized SSH public keys.
- Public keys are fetched via HTTP from a remote authorization server.
- Unauthorized users are denied access to push/fetch/clone.
-
🧳 Automatic Commit Backup on Push
- Every time a user pushes to a repo, the latest commit is zipped and stored in a local backup directory using the commit SHA as the filename.
-
🗂️ Repo Listing in SSH
- When a user connects without a Git command, the server lists available repositories and provides cloning instructions.
.
├── main.go # Main server logic
├── repos/ # Where Git repos are stored
├── repo_backups/ # Where commit zip backups are saved
├── .ssh/id_ed25519 # Host SSH private key (generated if missing)
Each repo has its own list of authorized public keys. When a user attempts any Git command (clone, fetch, push), the server:
-
Parses the command to extract the repo name.
-
Makes an HTTP GET request to:
http://your-auth-server.local/api/authorized_keys/<repo>
-
Compares the client's SSH key against the returned public keys.
-
Allows or denies access based on the match.
When a user performs a git push
, the server:
-
Extracts the latest commit SHA from the repo.
-
Compresses the entire
.git
directory of that repo into a zip file. -
Saves it at:
repo_backups/<repo>/<commit-sha>.zip
This acts as a simple versioned backup system.
git clone ssh://<host>:2222/my-repo.git
mkdir my-repo && cd my-repo
git init
git remote add origin ssh://<host>:2222/my-repo.git
git add .
git commit -m "Initial commit"
git push origin master
ssh-keygen -t ed25519 -C "your_email@example.com"
go run main.go
The server listens on 0.0.0.0:2222
.
In main.go
:
const (
port = "2222"
host = "0.0.0.0"
repoDir = "repos"
backupDir = "repo_backups"
authServer = "http://your-auth-server.local/api/authorized_keys"
)
repos/
— All Git repositories live here.repo_backups/
— Compressed.zip
backups of each pushed commit..ssh/id_ed25519
— SSH private key used to identify the server to clients.
- Charmbracelet Wish
- Charmbracelet SSH
- Charmbracelet log
- Golang SSH
git
(CLI must be installed and in PATH)
Built using:
- Add user-friendly web UI for repo browsing and key management
- Webhooks or post-receive Git hooks
- Fine-grained repo permission control (read vs write)