Skip to content

Commit fcb212f

Browse files
committed
Added restricted Git access with git-shell-commands
1 parent d889bc0 commit fcb212f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ RUN mkdir /git-server/keys \
2222
&& echo git:12345 | chpasswd \
2323
&& mkdir /home/git/.ssh
2424

25+
# This is a login shell for SSH accounts to provide restricted Git access.
26+
# It permits execution only of server-side Git commands implementing the
27+
# pull/push functionality, plus custom commands present in a subdirectory
28+
# named git-shell-commands in the user’s home directory.
29+
# More info: https://git-scm.com/docs/git-shell
30+
COPY git-shell-commands /home/git/git-shell-commands
31+
2532
# En sshd_config habilitamos acceso por key y deshabilitamos por password
2633
COPY sshd_config /etc/ssh/sshd_config
2734
COPY start.sh start.sh

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ How to run the container in port 2222 with two volumes, keys volume for public k
99

1010
How check that container works (you must to have a key):
1111

12-
$ ssh git@<ip-docker-server> -p 2222 -v
12+
$ ssh git@<ip-docker-server> -p 2222
13+
...
14+
Welcome to jkarlos/git-server-docker!
15+
You've successfully authenticated, but I do not
16+
provide interactive shell access.
17+
...
1318

1419
How clone a repository:
1520

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
printf '%s\n' "Welcome to jkarlos/git-server-docker!"
3+
printf '%s\n' "You've successfully authenticated, but I do not"
4+
printf '%s\n' "provide interactive shell access."
5+
exit 128

0 commit comments

Comments
 (0)