\$\begingroup\$
\$\endgroup\$
11
I want a git repository, accessible over ssh, to be read-only when used with certain keys. With other keys access to the full system is okay.
Here is my solution.
git-readonlyshell:
if echo "2ドル" | egrep -q ^git-upload-pack; then
sh -c "2ドル"
else
echo Error: read only access 1>&2
fi
.ssh/authorized_keys:
command="./git-readonlyshell -c \"$SSH_ORIGINAL_COMMAND\"" ...
Thoughts?
Any scenario in which this would break?
1 Answer 1
\$\begingroup\$
\$\endgroup\$
1
Should be
printf "%s\n" "2ドル" | grep -E "^git-upload-pack" && sh -c "2ドル"
Notes:
sh
notbash
for portability- The
printf
instead ofecho
is for safety. What happens if someone puts"-n foo"
as"2ドル"
?
ChrisWue
20.6k4 gold badges42 silver badges107 bronze badges
answered Nov 25, 2013 at 4:30
-
\$\begingroup\$ It is insecure. The
$SSH_ORIGINAL_COMMAND
can contain multiple command-lines, e.g.,git-upload-pack dummy; cat /etc/passwd
. \$\endgroup\$fumiyas– fumiyas2018年02月28日 07:26:55 +00:00Commented Feb 28, 2018 at 7:26
default
:
, meaninguser@server:/full/path/to/repo
\$\endgroup\$