Setup
I followed these steps:
$ useradd -m -d /path/to/git/ -s /bin/bash git
$ su - git
> mkdir /path/to/git/.ssh
> touch /path/to/git/.ssh/authorized_keys
> chmod 700 /path/to/git/.ssh
and then added my key to /path/to/git/.ssh.authorzied_keys
.
Then, after creating the repositories (see below), I logged out of git's account and:
$ sudo chsh -s /usr/bin/git-shell git
$ usermod -p '*' git
Create a repo
> mkdir /var/git/repository.git
> cd /var/git/repository.git
> git --bare init
Importing from GitHub
> git --bare fetch https://username@github.com/username/repository.git master:master
From a fresh local repo
localhost $ git remote add origin git@dev.example.com:repository.git
localhost $ git push origin master
To also push to GitHub for mirroring
localhost $ git remote set-url origin --add git@github.com:USERNAME/REPOSITORY.git
localhost $ git remote -v
origin git@git.fingers.today:REPOSITORY.git (fetch)
origin git@git.fingers.today:REPOSITORY.git (push)
origin git@github.com:USERNAME/REPOSITORY.git (push)