]> sipb.mit.edu Git - ikiwiki.git/blob - doc/tips/Git_repository_and_web_server_on_different_hosts.mdwn
ikiwiki (3.20140916) unstable; urgency=low
[ikiwiki.git] / doc / tips / Git_repository_and_web_server_on_different_hosts.mdwn
1 One may want to provide ikiwiki hosting with [[rcs/git]]+ssh access and web
2 server located at different hosts. Here's a description for such
3 a setup, using password-less SSH as a way of communication between
4 these two hosts.
5
6 [[!img separate-webserver.svg size=490x align=right]]
7
8 Git server
9 ==========
10
11 Let's create a user called `ikiwiki_example`. This user gets SSH
12 access restricted to GIT pull/push, using `git-shell` as a shell.
13
14 The root (bare) repository:
15
16 - is stored in `~ikiwki_example/ikiwiki_example.git`
17 - is owned by `ikiwiki_example:ikiwiki_example`
18 - has permissions 0700
19
20 The master repository's post-update hook connects via SSH to
21 `webserver` as user `ikiwiki_example`, in order to run
22 `~/bin/ikiwiki.update` on `webserver`; this post-update hook, located
23 in `~ikiwki_example/ikiwiki_example.git/hooks/post-update`, is
24 executable and contains:
25
26         #!/bin/sh
27         /usr/bin/ssh ikiwiki_example@webserver bin/ikiwiki.update
28
29 Password-less SSH must be setup to make this possible; one can
30 restrict `gitserver:ikiwiki_example` to be able to run only the needed
31 command on the web server, using such a line in
32 `webserver:~ikiwiki_example/.ssh/authorized_keys`:
33
34         command="bin/ikiwiki.update",from="gitserver.example.com",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ...
35
36 Web server
37 ==========
38
39 Let's create a user called `ikiwiki_example` on `webserver`. She needs
40 to have write permission to the destination directory.
41
42 The working tree repository (`srcdir`):
43
44 - is stored in `~ikiwki_example/src`
45 - is owned by `ikiwiki_example:ikiwiki_example`
46 - has permissions 0700
47 - has the following origin: `ikiwiki_example@gitserver:ikiwiki_example.git`
48
49 The CGI wrapper is generated with ownership set to
50 `ikiwiki_example:ikiwiki_example` and permissions `06755`.
51
52 Password-less SSH must be setup so that `ikiwiki_example@webserver` is
53 allowed to push to the master repository. As told earlier, SSH access
54 to `ikiwiki_example@gitserver` is restricted to GIT pull/push, which
55 is just what we need.
56
57 The Git wrapper is generated in `~ikiwiki_example/bin/ikiwiki.update`:
58
59         git_wrapper => '/home/ikiwiki_example/bin/ikiwiki.update'
60
61 As previously explained, this wrapper is run over SSH by the master
62 repository's post-update hook; it pulls updates from the master
63 repository and triggers a wiki refresh.