HostGitRb

By Raoul Felix

HostGitRb allows you to share your Git repositories with other users using SSH Public keys as authentication. You only need one shell account, which makes this great to use in a shared hosting environment, and users won’t be able to do anything else other than push/pull to the repositories you define.

Features

  • Easy to install
  • Git Repository sharing via SSH under one user (ideal for shared hosting)
  • User permission is based on their public keys
  • You can set read/write or read-only permissions
  • Users can only pull/push Git repos, they can’t login via SSH.

Installation

It’s easy as pie, just login to your server and install the gem: gem install hostgitrb

Alternatively, clone the HostGitRb repository from GitHub and add the bin/ directory to your PATH.

Usage

On my blog post introducing HostGitRb, Git Repo Hosting via SSH, I go through two use cases:

  • Use Case 1 – A simple scenario where I want to give a few users access to all the repositories under one project
  • Use Case 2 – Another scenario where a user needs to have access to a repository that’s shared with another user

Reference

Running hostgitrb --help will give you a list of possible options you can use (thanks to Trollop):


> hostgitrb --help
Options:
          --file, -f <s>:  Set path to public ssh key file (default: )
           --key, -k <s>:  Provide public ssh key as a string (default: )
           --dir, -d <s>:  Set full path to directory with git repositories to 
                           allow access to (default: )
          --readonly, -r:  Set access to repositories in --dir to read only
          --nobackup, -n:  Don't make backup of authorized_keys file
--authorizedkeys, -a <s>:  Set authorized_keys file (default: ~/.ssh/authorized_keys)
              --help, -h:  Show this message

They’re pretty much self-explanatory, but here are a few notes:

  • Use --key when you have the SSH public key is in the clipboard (don’t forget the "" due to spaces)
  • Use --file when you have the actual public key file on your server.
  • --readonly makes sure the user can only execute git pull
  • HostGitRb makes backups of the authorized_keys file it modifies; stop this with --nobackup
  • --authorizedkeys allows you to change the file that the new permission is added to.