Simple and lightweight SSH git hosting with just a directory.

go-gitdir

Go Report Card Build Status

This project makes it incredibly easy to host a secure git server with a config that can be easily rolled back.

It aims to solve a number of problems other git servers have:

  • Requires no external dependencies other than the binary and git
  • Stores its configuration in a repo managed by itself
  • Doesn't hook into the system's user accounts
  • No vendor lock-in - everything is just a bare git repository

Origins

The main goal of this project is to enable simple git hosting when a full solution like Bitbucket, Github, Gitlab, Gitea, etc is not needed.

This project was inspired by gitolite and gitosis, but also includes a built-in ssh server and some additional flexability. It is not considered stable, but should be usable enough to experiment with.

Thankfully because all the repos are simply stored as bare git repositories, it should be fairly simple to migrate to or from other git hosting solutions. There is no vendor lock-in.

Requirements

Build requirements:

  • Go >= 1.13

Runtime requirements:

  • git (for git-receive-pack and git-upload-pack)

Building

Clone the repository somewhere, outside the GOPATH. Then, from the root of the source tree, run:

go build

This will create a binary called go-gitdir.

Running

Server Config

There are a number of environment variables which can be used to configure your go-git-dir instance.

The following are required:

  • GITDIR_BASE_DIR - A directory to store all repositories in. This folder must exist when the service starts up.

The following are optional:

  • GITDIR_BIND_ADDR - The address and port to bind the service to. This defaults to :2222.
  • GITDIR_LOG_READABLE - A true value if the log should be human readable
  • GITDIR_LOG_DEBUG - A true value if debug logging should be enabled

Runtime Config

The runtime config is stored in the "admin" repository. It can be cloned and modified by any admin on the server. In it you can specify groups (groupings of users for config or convenience reasons), repos, and orgs (groupings of repos managed by a person).

Additionally, there are a number of options that can be specified in this file which change the behavior of the server.

  • implicit_repos - allows a user with admin access to that area to create repos by simply pushing to them.
  • user_config_keys - allows users to specify ssh keys in their own config, rather than relying on the main admin config.
  • user_config_repos - allows users to specify repos in their own config, rather than relying on the main admin config.
  • org_config_repos - allows org admins to specify repos in their own config, rather than relying on the main admin config.

Usage

Simply run the built binary with GITDIR_BASE_DIR set and start using it!

On first run, go-git-dir will push a commit to the admin repo with a sample config as well as generated server ssh keys. These can be updated at any time (even at runtime) but if the server restarts and the keys cannot be loaded, they will be re-generated.

Note that you will need to manually clone the admin repository (at $GITDIR_BASE_DIR/admin/admin) to add a user to config.yml and set them as an admin.

Sample Config

Sample admin config.yml:

users:
  belak:
    is_admin: true
    keys:
      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDeQfBUWIqpGXS8xCOg/0RKVOGTnzpIdL7r9wK1/xA52 belak@tmp
    repos:
      personal-gitdir: {}

groups:
  admins:
    - belak

repos:
  go-gitdir:
    public: true

    write:
      - $admins
    read:
      - some-other-user

orgs:
  vault:
    admins:
      - $admins
    write:
      - some-org-user
    read:
      - some-other-org-user

    repos:
      the-vault:
        write:
          - some-repo-access-user

options:
  implicit_repos: false
  user_config_keys: true
  user_config_repos: false
  org_config_repos: false

Repo Creation

All repos defined in the config are created when the config is loaded. At runtime, if implicit repos are enabled, trying to access a repo where you have admin access will implicitly create it.

Comments
  • Failed to load SSH server

    Failed to load SSH server

    I get the following error:

    bvk@milk:~$ GITDIR_BASE_DIR=/tmp/git ~/go/bin/go-gitdir serve
    {"level":"info","time":"2019-10-30T15:27:47-07:00","message":"Starting go-git-dir"}
    {"level":"info","time":"2019-10-30T15:27:47-07:00","message":"Reloading"}
    {"level":"fatal","error":"ssh: unsupported key type ed25519.PublicKey","time":"2019-10-30T15:27:47-07:00","message":"Failed to load SSH server"}
    bvk@milk:~$
    
    bvk@milk:/tmp/git/admin/admin$ git log
    commit e24c9cd7a1fe75a6d14b93b36261f08c2770c2a0
    Author: root <root@localhost>
    Date:   Wed Oct 30 15:26:33 2019 -0700
    
        Updated ssh keys
    
    commit a608461d301832d3bd9996c962be9e12511157e0
    Author: root <root@localhost>
    Date:   Wed Oct 30 15:25:36 2019 -0700
    
        Updated user bvk
    
    commit 094ad53a02c79bf3917c05c3dc7dc18a5cfba829
    Author: root <root@localhost>
    Date:   Wed Oct 30 15:25:10 2019 -0700
    
        Updated user bvk
    bvk@milk:/tmp/git/admin/admin$
    
  • Cleanup Dockerfile

    Cleanup Dockerfile

    This adds 2 new settings: GITDIR_ADMIN_USER, and GITDIR_ADMIN_PUBLIC_KEY, which allow gitdir to auto-add a public key to the config on startup. This greatly simplifies the setup process and lines up with how many services are run in docker.

    Unfortunately, between the last commit and now, travis-ci dropped their free option, so the CI is also being migrated to Github Actions. Finally, all packages and linters have been updated to their latest versions.

  • Add Dockerfile and other related files to enable container support

    Add Dockerfile and other related files to enable container support

    This Pull Requests adds Dockerfile, docker-compose.yaml and .dockerignore for gitdir, allowing the project to be deployed as a Docker container.

    I personally tested the files and the build process without issue. Tested platforms: AMD64 and ARM32v7.

    However, these file are still experimental, if you're interested, please give it a try and send feedback.

    My main worry is about a little script called gitdir_config that I embeded into the image. The script is intended to help first-timers to initialize gitdir during their first run. However, the script is little hacky, I'm not sure I did what should've been done. So please give it a look.

    Thanks!

  • unknown location of executable

    unknown location of executable

    After running 'go build' as per the install instructions, there doesn't seem to be an executable generated... could you update the README with the location of the resulting binary.

  • Migrate to go-git

    Migrate to go-git

    This gives us a number of things:

    • A cleaner interface to git commands
    • A binary that doesn't need to link with libgit2
    • A binary that doesn't need libgit2 at runtime

    Fixes #14

  • Clean up code

    Clean up code

    The first version was pushed out pretty quickly - it was built in only a few days. As a result of this, there are a number of things that should be cleaned up:

    • [x] Merge repo and *GitRepo types (or more clearly separate them)
    • [x] All admin repo accesses to the getter functions
    • [x] ~Don't bother storing the *Config in the context~ (this is still relevant, unfortunately)
    • [x] ~Avoid passing config options all over the place~ (there's not a good way around this)
    • [x] Change to the basedir to make repo creation/lookup simpler
  • Update Readme

    Update Readme

    Can you please add some details in the Readme? I want to try the following

    a. Create a repo dynamically. I'm not clear what needs to be set in the config file. b. Add/Remove user to the repo. How do I add/remove a user?

    Detailed instructions will be very useful.

Related tags
Gsshrun - Running commands via ssh on the server/hosting (if ssh support) specified in the connection file

Gsshrun - Running commands via ssh on the server/hosting (if ssh support) specified in the connection file

Sep 8, 2022
Extended ssh-agent which supports git commit signing over ssh

ssh-agentx ssh-agentx Rationale Requirements Configuration ssh-agentx Configuration ssh-gpg-signer Linux Windows Signing commits after configuration T

Jun 29, 2022
Server for hosting a Munki repository and dynamically generating manifests

About munki-server is an all-in-one server to deploy Munki with three main parts: HTTP file server for Munki clients Simple dynamic manifest generatio

Dec 7, 2021
🤘 The native golang ssh client to execute your commands over ssh connection. 🚀🚀
🤘 The native golang ssh client to execute your commands over ssh connection. 🚀🚀

Golang SSH Client. Fast and easy golang ssh client module. Goph is a lightweight Go SSH client focusing on simplicity! Installation ❘ Features ❘ Usage

Dec 24, 2022
Golang `net/rpc` over SSH using installed SSH program

Golang net/rpc over SSH using installed SSH program This package implements a helper functions to launch an RPC client and server. It uses the install

Nov 16, 2022
A library designed for hosting Minecraft: Java Edition listeners.

expresso A library designed for hosting Minecraft: Java Edition listeners. Features Hosting listeners. All handshake, status, and login state packets.

Jul 29, 2022
A modified version of RoProxy made for self-hosting.

roproxy-lite A modified version of RoProxy made for self-hosting. Setup is easy, simply change the options at the top of main.go and run. Alternativel

Dec 24, 2022
Switch git user easily with ssh identity.
Switch git user easily with ssh identity.

gitusr A cli tool to easily manage multiple git users and their ssh identity. Add a new git user to gitusr config. Delete a git user from gitusr confi

Aug 22, 2021
Examples using the stomp package from git://github.com/gmallard/stompngo.git

stompngo_examples - A collection of examples for package stompngo Features Full demonstration of support for STOMP protocols: Protocol Level 1.0 Proto

Jan 22, 2021
Caddy-git - Git Plugin for Caddy v2

caddy-git Git Plugin for Caddy v2. Inspired by this comment. Please ask question

Jan 1, 2023
Goph - A lightweight Go SSH client focusing on simplicity
Goph - A lightweight Go SSH client focusing on simplicity

Golang SSH Client. Fast and easy golang ssh client module. Goph is a lightweight

Oct 30, 2022
Just Enough C2 - A simple but effective server and implant

Just Enough C2 An opinionated C2 server and implant which does Just Enough to be effective. Meant primarily for small teams operating on small numbers

Dec 1, 2022
It is a proxy to improve article readability, a directory for your favorite articles, and a way to make the internet lighter and more accessible.

timoneiro It is a work in progress. Some features are unimplemented yet. The helmsman's goal is to be a way to browse articles without all the distrac

Jun 13, 2022
TProx is a fast reverse proxy path traversal detector and directory bruteforcer.
TProx is a fast reverse proxy path traversal detector and directory bruteforcer.

TProx is a fast reverse proxy path traversal detector and directory bruteforcer Install • Usage • Examples • Join Discord Install Options From Source

Nov 9, 2022
Go-wd - Get the same working directory path at 'go run' and after 'go build'

go-wd Get the same working directory path at 'go run' and after 'go build' Usage

Jan 30, 2022
Just another "what is my IP address" service, including geolocation and headers information

What is my IP address What is my IP address Features Endpoints Build Usage Examples Run a default TCP server Run a TLS (HTTP/2) server only Run a defa

Nov 21, 2022
A simple abstraction around ssh and sftp libraries in Go(Golang).

sshx A simple abstraction around ssh and sftp libraries in Go(Golang). Resources Installation Installation Install sshx as you normally would for any

Dec 14, 2022
turn a directory into a GUI, slash example of VNC-based GUI

dirgui @rsnous on Jan 11, 2021: "idea: filesystem<->GUI adapter, where a directory turns into a form, executable files inside that directory turn into

May 3, 2022
Protect any Kubernetes application with Azure Active Directory authentication
Protect any Kubernetes application with Azure Active Directory authentication

Azure Active Directory Proxy Covers any app with active directory authentication How does it work You gonna need to register an app in your Azure Acti

Jan 25, 2022