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