├── Dockerfile └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | ## Standard phusion part 2 | FROM phusion/baseimage:latest 3 | ENV HOME /root 4 | RUN /etc/my_init.d/00_regen_ssh_host_keys.sh -f && rm -f /etc/service/sshd/down # Uncomment to Enable SSHD 5 | #RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh # Uncomment to Disable SSHD 6 | CMD ["/sbin/my_init"] 7 | 8 | ## Expose ports. 9 | EXPOSE 22 10 | 11 | ## Application specific part 12 | MAINTAINER Stephen Day 13 | WORKDIR /tmp 14 | RUN apt-get -qq update && apt-get -qq upgrade 15 | RUN apt-get -qq install git-sh git sharutils 16 | 17 | ## Setup service 18 | # Setup a git user and SSH 19 | RUN groupadd -g 987 git && useradd -g git -u 987 -d /git -m -r -s /usr/bin/git-shell git 20 | RUN sed -i -e 's/.*LogLevel.*/LogLevel VERBOSE/' -e 's/#*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config 21 | RUN sed -i -e 's/#UsePAM.*/UsePAM no/' /etc/ssh/sshd_config 22 | #Set a long random password to unlock the git user account 23 | RUN usermod -p `dd if=/dev/urandom bs=1 count=30 | uuencode -m - | head -2 | tail -1` git 24 | 25 | ## Remove /etc/motd 26 | RUN rm -rf /etc/update-motd.d /etc/motd /etc/motd.dynamic 27 | RUN ln -fs /dev/null /run/motd.dynamic 28 | 29 | ## Clean up 30 | WORKDIR / 31 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 32 | 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | git-ssh-server 2 | ================= 3 | 4 | A minimal GIT server. 5 | 6 | Build instructions 7 | ================== 8 | 9 | git clone https://github.com/unixtastic/git-ssh-server 10 | docker build -t 'unixtastic/git-ssh-server' . 11 | 12 | Usage instructions 13 | ================== 14 | 15 | To run this first create a data directory on your docker host to hold git data, ssh authentication, 16 | and possibly git-shell-commands. 17 | 18 | mkdir /docker_data/git 19 | 20 | Run the container. 21 | 22 | docker run -d -p 2222:22 -v /docker_data/git:/git unixtastic/git-ssh-server 23 | 24 | You may substitute '2222' with any port number of your choosing. 25 | 26 | Add users 27 | --------- 28 | 29 | Setup SSH: 30 | 31 | cd /docker_data/git 32 | mkdir .ssh 33 | chown -R 987:987 .ssh 34 | chmod -R 700 .ssh 35 | touch .ssh/authorized_keys 36 | chmod 600 .ssh/authorized_keys 37 | 38 | Add user public keys to `.ssh/authorized_keys` just like you would do for 'normal' SSH. 39 | 40 | touch /docker_data/git/.hushlogin to prevent login banners that can confuse git. 41 | 42 | Setup repos 43 | ----------- 44 | 45 | mkdir /docker_data/git/mynewproject.git 46 | cd /docker_data/git/mynewproject.git 47 | git --bare init 48 | chown -R 987:987 . 49 | 50 | Clone the repo from a client: 51 | 52 | git clone ssh://git@myserver:2222/git/mynewproject.git 53 | 54 | Setup git-shell-commands 55 | ------------------------ 56 | 57 | mkdir /docker_data/git/git-shell-commands 58 | chown 987:987 /docker_data/git/git-shell-commands 59 | chmod 700 /docker_data/git/git-shell-commands 60 | 61 | Add your commands to the above directory. You might want to start with list, which 62 | you can find under `/usr/share/doc` on most git client machines. 63 | 64 | Notes 65 | ===== 66 | 67 | The SSH host keys are generated at the first run of each new container. This will confuse some git clients and really should be changed. 68 | --------------------------------------------------------------------------------