switch to Python 3; allow command verifiers to change the command
[schsh.git] / README.txt
1 = Introduction =
2
3 This is schsh, a schroot-based shell. 
4 The purpose is simple: I want to provide users with scp, sftp and rsync access
5 to my server, such that they can only operate in a certain subdirectory.
6 There are plenty of solutions out there, and all have one drawback in common:
7 You need to manually set up a bunch of chroots, and copy the files needed for
8 scp, sftp and rsync into them.
9 I didn't like that, so here is my alternative solution: Use schroot for the
10 chroots. This gets OpenSSH out of the loop when it comes to chroots, instead
11 the relevant users get a special shell (schsh, the schroot shell). That shell
12 essentially calls schroot and runs the desired command inside the chroot. It
13 also provides some very basic command restriction (so that you can allow scp,
14 sftp and rsync and nothing else), but for a more sophisticated command
15 filtering you can nest this with something like rush[0].
16 Unfortunately, this still needs a (s)chroot to be set up for each user, but at
17 least no files have to be copied: Instead, schroot is configured to bind-mount
18 /bin, /lib, /usr/bin and /usr/lib into the user-chroot. Hence no files are
19 duplicated, and system updates to the relevant tools are applied inside the
20 chroots automatically.
21
22
23 [0] http://www.gnu.org.ua/software/rush/
24
25 = Setup =
26
27 Dependencies:
28 schsh needs Python 2 (I tested it with version 2.7) and schroot.
29
30 Installation is simple: Just run "make install". That will copy two files
31 to /usr/local/bin, and some configuration to /etc/schroot/.
32 Before you create any users, make sure the directory /var/lib/schsh and a
33 group called "schsh" exist.
34
35 Before you can set up schsh for a user, you need to create it first:
36 $ adduser sandboxed --disabled-password
37
38 Any existing user can be "sandboxed" by running
39 $ /usr/local/bin/makeschsh sandboxed
40 This does the following:
41 * Change the user's shell to /usr/local/bin/schsh
42 * Create a chroot base in /var/lib/schsh/sandboxed with some empty subfolders
43   as well as /etc/passwd and /etc/group containing only root, this user and
44   the "schsh" group
45 * Add the user to the "schsh" group
46 * Add a schroot called schsh-sandboxed for the given folder, and an fstab file
47   in /etc/schroot/schsh used by this schroot
48
49 Now if the user logs in via SSH, /usr/local/bin/schsh will be executed, and
50 it will lock the user into the schroot schsh-sandboxed. It will only see
51 /bin, /lib, /usr/bin and /usr/lib and a folder called /data mapped to
52 /home/sandboxed/data. If you want to give the user access to more folders,
53 or another folder, simply edit /etc/schroot/schsh/sandboxed.fstab.
54
55 = Configuration =
56
57 There is not much to configure at the moment. However, there are some
58 global variables at the top of both Python scripts to change the base
59 paths, and to tell which commands are allowed.