File tree Expand file tree Collapse file tree 6 files changed +29
-2
lines changed Expand file tree Collapse file tree 6 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 11FROM alpine:latest
22
33LABEL org.opencontainers.image.authors="Oliver Filla <https://github.com/ofilla>, Carlos Bernárdez <carlos@z4studios.com>"
4+ LABEL maintainer='Carlos Bernárdez <carlos@z4studios.com>'
45
56RUN apk add --no-cache openssh git
67
78# -D flag avoids password generation
89# -s flag changes user's shell
910RUN adduser -D -s /usr/bin/git-shell git \
1011 && passwd -u git \
11- && mkdir -p /git-server/keys /git-server/repos ~git/.ssh
12+ && mkdir -p /git-server/keys /git-server/repos /opt/etc/ssh ~git/.ssh
13+
14+ WORKDIR /git-server/
15+
1216
1317# This is a login shell for SSH accounts to provide restricted Git access.
1418# It permits execution only of server-side Git commands implementing the
@@ -23,4 +27,5 @@ COPY start.sh start.sh
2327
2428EXPOSE 22
2529
30+ VOLUME ["/git-server/keys" , "/opt/etc/ssh" , "/git-server/repos" ]
2631CMD ["sh" , "start.sh" ]
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ $ git clone ssh://git@<ip-docker-server>:2222/git-server/repos/myrepo.git
6363* ** Volumes** :
6464 * ` /git-server/keys ` : Volume to store the users public keys
6565 * ` /git-server/repos ` : Volume to store the repositories
66+ * ` /git-server/host-keys ` : Volume to store the SSHd host keys
6667
6768### SSH Keys
6869
Original file line number Diff line number Diff line change @@ -9,4 +9,8 @@ services:
99 volumes :
1010 - ${GIT_SERVER_KEYS_DIR:-~/git-server/keys}:/git-server/keys:ro
1111 - ${GIT_SERVER_REPO_DIR:-~/git-server/repos}:/git-server/repos
12+ - host_keys:/opt/etc/ssh
1213
14+ volumes :
15+ host_keys :
16+ name : git-server-host-keys
Original file line number Diff line number Diff line change 22printf ' %s\n' " Welcome to git-server-docker!"
33printf ' %s\n' " You've successfully authenticated, but I do not"
44printf ' %s\n' " provide interactive shell access."
5+
6+ printf ' \n'
7+ printf ' %s\n' " The following repositories are available:"
8+ for REPO in /git-server/repos/*
9+ do
10+ printf ' %s\n' " - $( basename ${REPO% .git} ) "
11+ done
12+
13+ printf ' \n'
14+ printf ' %s\n' " To clone, use the following URL:"
15+ printf ' %s\n' " ssh://git@<SERVER>:<PORT>/git-server/repos/<REPO_NAME>.git"
16+
517exit 128
Original file line number Diff line number Diff line change @@ -7,3 +7,8 @@ AllowUsers git
77X11Forwarding no
88AllowTcpForwarding no
99PermitTTY no
10+
11+ # host keys at different path
12+ HostKey /opt/etc/ssh/ssh_host_rsa_key
13+ HostKey /opt/etc/ssh/ssh_host_ecdsa_key
14+ HostKey /opt/etc/ssh/ssh_host_ed25519_key
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ _term() {
88trap _term SIGTERM
99
1010# generate host keys, if required
11- ssh-keygen -A
11+ ssh-keygen -A -f /opt
1212
1313# If there are some public keys in keys folder
1414# then it copies its contain in authorized_keys file
You can’t perform that action at this time.
0 commit comments