Limited Shell#
A wrapper of /bin/sh that limits the available commands.
Useful if you want to harden your CD pipelines.
Usage#
- Change the default shell of the user to
/usr/local/bin/limited-shell(or/usr/bin/limited-shell). - Create the config directory
/etc/limited-shell. - Create the file
/etc/limited-shell/user(replaceuserby its username). - List allowed commands in this file. You can use
*to allow every subcommands.
Now, the user can only use the listed commands.
Build#
This project uses Zig 0.16.
Build it with:
zig build
The binary is in ./zig-out/bin/limited-shell.
Then, you can install it with:
sudo install -m 755 -o root:root ./zig-out/bin/limited-shell /usr/local/bin/limited-shell
Doc#
The manpages are written with scdoc.
You can generate them with:
scdoc < docs/limited-shell.1.scd > docs/limited-shell.1
scdoc < docs/limited-shell.5.scd > docs/limited-shell.5
And you can install them with:
sudo install -m 755 ./docs/limited-shell.1 /usr/local/man/man1/
sudo install -m 755 ./docs/limited-shell.5 /usr/local/man/man5/