]> git.netwichtig.de Git - user/henk/code/schleuder-website.git/blob - schleuder/docs/server-admins.md
19594377e6417892812eebf926d57c3cf2a123c8
[user/henk/code/schleuder-website.git] / schleuder / docs / server-admins.md
1 ---
2 title: Documentation for server-admins
3 ---
4
5 {% include docs-head.md version=4.0 %}
6
7
8 ## Setup Schleuder
9
10 ### Installation
11
12 You can install schleuder either from Linux distribution packages or rubygems. Currently there are supported distribution packages for Debian ("buster" and above), CentOS 7 and Archlinux (via AUR). If you use one of the directly supported platforms, you should choose the packages over the gems.
13
14 {: .note}
15 Don't use the packages provided by Ubuntu in all releases up to and including 17.10, they are severely outdated. On Ubuntu 18.04 only use the package if it has at least version 3.2.2.
16
17 Besides schleuder you should also install at least one of [schleuder-cli](https://0xacab.org/schleuder/schleuder-cli) (the command line tool to manage Schleuder lists), and [schleuder-web](https://0xacab.org/schleuder/schleuder-web) (the web interface to manage and maintain Schleuder lists).
18
19 Additionally we recommend running an entropy source such as `haveged`. This ensures Schleuder won't be blocked by lacking entropy, which otherwise might happen e.g. during key generation.
20
21 #### Debian
22
23 {: .note}
24 The step needs root privileges
25
26 We maintain schleuder and schleuder-cli in "buster" and above. (For production usage we recommend Debian "buster".)
27 To install the packages
28
29     apt-get install schleuder schleuder-cli
30
31 Running `schleuder install` afterwards isn't necessary, the package takes care of it.
32
33 #### CentOS
34
35 For CentOS 7 there is a maintained [copr-repository](https://copr.fedorainfracloud.org/coprs/schleuder/schleuder/) using [Software Collections](https://www.softwarecollections.org/en/).
36
37 {: .note}
38 All steps need root privileges
39
40 Install the repository & the SCL repository
41
42     yum install centos-release-scl
43     curl -o /etc/yum.repos.d/schleuder-schleuder-epel-7.repo https://copr.fedorainfracloud.org/coprs/schleuder/schleuder/repo/epel-7/schleuder-schleuder-epel-7.repo
44
45 Now you are ready to install schleuder and schleuder-cli
46
47     yum install schleuder schleuder-cli
48
49 Afterwards run `schleuder install` to finalize the setup of Schleuder. This creates necessary directories, copies example configs, etc. If you see errors about missing write permissions please follow the advice given.
50
51 {: .note}
52 The copr-repository also provides you with a package for [schleuder-web](https://0xacab.org/schleuder/schleuder-web/). Please read the documentation of schleuder-web on how to get it up and running.
53
54 #### Archlinux
55
56 For archlinux there are the [AUR](https://wiki.archlinux.org/title/Arch_User_Repository) packages for [schleuder](https://aur.archlinux.org/packages/schleuder/) and [schleuder-cli](https://aur.archlinux.org/packages/schleuder-cli/).
57
58 See the [official AUR documentation](https://wiki.archlinux.org/title/Arch_User_Repository#Installing_and_upgrading_packages) on how to install AUR packages or use one of the many available [AUR helpers](https://wiki.archlinux.org/title/AUR_helpers) to manage AUR dependencies.
59
60 Once you have installed the `schleuder` package you need to run `schleuder install` as the created schleuder system user. See also the [schleuder wiki page](https://wiki.archlinux.org/title/Schleuder) for information about installation and configuration.
61
62 #### From Ruby-Gem
63
64 For instructions on how to install from rubygems please see the [README](https://0xacab.org/schleuder/schleuder/blob/main/README.md#installing-schleuder) of Schleuder.
65
66
67 #### Automation
68
69 To ease the installation and configuration of schleuder, schleuder-cli and schleuder-web, and to help with the creation and deletion of lists, you can rely either on...
70
71 * an [ansible role](https://github.com/systemli/ansible-role-schleuder), which works for Debian, or
72
73 * a [puppet module](https://0xacab.org/schleuder/puppet-schleuder). Currently it works for CentOS 7, but we would like to make it work for Debian as well - help would be highly appreciated.
74
75
76 ### Configuration
77
78 Schleuder reads its **basic settings** from a file that it by default expects at `/etc/schleuder/schleuder.yml`. To make Schleuder read a different file set the environment variable `SCHLEUDER_CONFIG` to the path to your file when running schleuder. E.g.:
79
80     SCHLEUDER_CONFIG=/usr/local/etc/schleuder.yml /path/to/bin/schleuder ...
81
82 For explanations of the possible settings read the default config file (also [available in the repository](https://0xacab.org/schleuder/schleuder/blob/main/etc/schleuder.yml)).
83
84 The **default settings for new lists** are read from another config file. By default Schleuder looks at `/etc/schleuder/list-defaults.yml`. To make Schleuder read a different file set the environment variable `SCHLEUDER_LIST_DEFAULTS` analogous to above. The possible settings are explained in the default config file, which is [also available in the repository](https://0xacab.org/schleuder/schleuder/blob/main/etc/list-defaults.yml).
85
86 Once a list is created, it is not affected by these configuration files any more. Existing lists have their configuration stored in the database. The settings in the database can be shown and set via the schleuder API, available through schleuder-web or schleuder-cli. Run `schleuder-cli lists help` and `schleuder-cli lists list-options` for more information on the latter.
87
88 ### Hook into Mail Transport Agent
89
90 In "work"-mode, Schleuder expects the list's email-address as second argument (first one is "work") and the incoming email on standard-input.
91
92 To enable Schleuder to receive emails, your Mail Transport Agent must be configured accordingly. How to do this with Postfix is documented in detail below.
93
94 #### Postfix
95
96 {: .note}
97 This section describes only those parts of a Postfix-setup that are relevant to Schleuder. We assume that you have a sensible and tested Postfix-setup already.
98
99 Firstly, to hook Schleuder into Postfix adapt these lines (path and maybe user) and add them to `master.cf`:
100
101     schleuder  unix  -       n       n       -       -       pipe
102       flags=DRhu user=schleuder argv=/path/to/bin/schleuder work ${recipient}
103
104 Then you have to chose how postfix should decide if a message should be delivered to Schleuder. There are two options:
105
106 1. Configure it for each list individually. That's the way to go if you don't run many lists, or use the respective domain also for a varying number of email accounts or aliases.
107 2. Dedicate a whole domain to Schleuder. That's the way to go if you run more lists than email accounts or aliases on that domain.
108
109
110 **To configure each list individually,** add these lines to `main.cf`:
111
112     schleuder_destination_recipient_limit = 1
113     transport_maps = hash:/etc/postfix/transport_schleuder
114
115 Now adapt the following lines for each list and add them to `/etc/postfix/transport_schleuder`:
116
117     foo@example.org          schleuder:
118     foo-request@example.org  schleuder:
119     foo-owner@example.org    schleuder:
120     foo-bounce@example.org   schleuder:
121     foo-sendkey@example.org  schleuder:
122
123 Afterwards run `postmap /etc/postfix/transport_schleuder` and restart postfix. Remember to repeat this also for newly created lists later.
124
125
126 Another way to tell postfix which domain and list can be piped to schleuder is to get that information out of the sqlite database. A requirement for that is the postfix-sqlite package, which isn't in the standard repositories of CentOS, but Debian.
127
128 **To dedicate a whole domain to Schleuder,** add these lines to `main.cf`:
129
130     schleuder_destination_recipient_limit = 1
131     virtual_mailbox_domains = sqlite:/etc/postfix/schleuder_domain_sqlite.cf
132     virtual_transport       = schleuder
133     virtual_alias_maps      = hash:/etc/postfix/virtual_aliases
134     virtual_mailbox_maps    = sqlite:/etc/postfix/schleuder_list_sqlite.cf
135
136 Then adapt and add at least the following exceptions from the All-to-Schleuder-rule to `/etc/postfix/virtual_aliases`:
137
138     postmaster@lists.example.org    root@anotherdomain
139     abuse@lists.example.org         root@anotherdomain
140     MAILER-DAEMON@lists.example.org root@anotherdomain
141     root@lists.example.org          root@anotherdomain
142
143 Afterwards run `postmap /etc/postfix/virtual_aliases`.
144
145 The file `schleuder_domain_sqlite.cf` can ask the schleuder sqlite database (this will delegate the whole domain to schleuder):
146
147     dbpath = /var/lib/schleuder/db.sqlite
148     query = select distinct substr(email, instr(email, '@') + 1) from lists
149             where email like '%%%s'
150
151 And the file `schleuder_list_sqlite.cf` can also get the information from the schleuder sqlite database:
152
153     dbpath = /var/lib/schleuder/db.sqlite
154     query = select 'present' from lists
155               where email = '%s'
156               or    email = replace('%s', '-bounce@', '@')
157               or    email = replace('%s', '-owner@', '@')
158               or    email = replace('%s', '-request@', '@')
159               or    email = replace('%s', '-sendkey@', '@')
160
161 From now on each Schleuder-list will instantly be reachable by email once it was created.
162
163 #### Exim
164
165 {: .note}
166 This section describes only those parts of a Exim-setup that are relevant to Schleuder. We assume that you have a sensible and tested Exim-setup already.
167
168 As with any exim email routing, we need to configure essentially a router that accepts and directs a mail to a transport, which knows how to hand-over an email to schleuder.
169
170 Within the `begin routers` section of your `exim.conf` you can add the following router:
171
172     mlschleuder:
173       driver = accept
174       address_data = ${lookup sqlite,file=/var/lib/schleuder/db.sqlite {select email from lists where email = '${quote_sqlite:${local_part}@${domain}}'} {$value} fail}
175       local_part_suffix_optional
176       local_part_suffix = +* : -bounce : -sendkey : -request : -owner
177       transport = mlschleuder_transport_local
178
179 This router will look directly in schleuder’s sqlite file to check if the given recipient is a legitimate list’s email address. For this to work, exim needs to be able to read that file. One approach to achieve this is to add the user exim is running as to the group the file belongs to and make the file group-readable. For Debian the following commands will achieve that:
180
181     adduser Debian-exim schleuder
182     chmod g+r /var/lib/schleuder/db.sqlite
183
184 If that is not possible, you can instead add the following router:
185
186     mlschleuder:
187       driver = accept
188       require_files = /etc/exim/schleuder-lists
189       address_data = ${lookup {$local_part@$domain} lsearch,ret=key {/etc/exim/schleuder-lists} {$value} fail}
190       local_part_suffix_optional
191       local_part_suffix = +* : -bounce : -sendkey : -request : -owner
192       transport = mlschleuder_transport_local
193
194 `/etc/exim/schleuder-lists` is a simple textfile containing one list-address per line. You can for example create it by executing `schleuder-cli lists list > /etc/exim/schleuder-lists` after creating or deleting any lists.
195
196 In more advanced setups you might have different conditions depending on how you manage the inventory of your schleuder lists and decide to accept a mail for a list.
197
198 Within the `begin transports` section of your `exim.conf` you then configure the transport:
199
200     mlschleuder_transport_local:
201        driver = pipe
202        user = schleuder
203        group = schleuder
204        # schleuders generates nice log messages for some of the problems
205        return_fail_output = true
206        home_directory = /var/lib/schleuder/lists/${domain:$address_data}/${local_part:$address_data}
207        command = "/usr/bin/schleuder work ${local_part:$address_data}${local_part_suffix}@${domain:$address_data}"
208        message_size_limit = 10M
209
210 Please note that we keep the `$local_part_suffix` when handing the mail over to schleuder, so schleuder can e.g. detect bounces or sendkey emails properly.
211
212 Restart exim and you have your working schleuder+exim setup.
213
214 Remember to repeat dumping the list of schleuder-lists to `/etc/exim/schleuder-lists` also for newly created lists later.
215
216 ### Schleuder API
217
218 The Schleuder API is provided by `schleuder-api-daemon`. Configuration clients (schleuder-web, schleuder-cli) use it to access information about lists, subscriptions, and keys. As you probably want to at least use schleuder-cli from localhost, setting up schleuder-api-daemon is useful even without remote clients.
219
220 {: .note}
221 Schleuder does **not** use schleuder-api-daemon to process emails. You can stop schleuder-api-daemon at any time without breaking the email flow.
222
223 To run `schleuder-api-daemon`, depending on the type of operating system and the setup you are using, you can either start the systemd-unit-file:
224
225     systemctl start schleuder-api-daemon
226
227 Or you can run it manually in a shell:
228
229     schleuder-api-daemon
230
231 {: .note}
232 Please take care to run `schleuder-api-daemon` as the user that owns the directory of schleuder lists (by default `/var/lib/schleuder/lists`) to avoid running into file permission problems!
233
234 #### Transport encryption
235
236 schleuder-api-daemon uses transport encryption (TLS) for all connections. The required TLS-certifcates should have been generated during the setup (`schleuder install`). You can generate new ones at any time by executing:
237
238     schleuder cert generate
239
240 If the file systems permissions allow it, Schleuder will write the certificate and the key directly into the correct files (paths are read from the configuration file). Otherwise you might have to move them. Please read the output of the above command for possible instructions.
241
242 In case you already have a suitable certificate you can use that, too. Its hostnames do not matter. Just copy it to the paths specified in the configuration file, or change those paths.
243
244 In order to verify the connection, each client needs to know the fingerprint of the API-certificate. The fingerprint will be shown when generating the certificates. Later you can always have it show again by executing this:
245
246     schleuder cert fingerprint
247
248 {: .note}
249 Use secure channels to transport this information!
250
251 #### Authentication
252
253 The Schleuder API uses API-keys to authenticate clients.
254
255 You can generate new API-keys by executing:
256
257     schleuder new_api_key
258
259 To enable the client to connect, their API-key must be added to the section `valid_api_keys` in Schleuder's configuration file.
260
261 {: .note}
262 Provide each client with their own API-key, and use secure channels to transport this information!
263
264 {: .note}
265 There is **no authorization of clients,** yet. Each client is allowed every action. So be wary who to give an API-key to. schleuder-web does its own authorization, but schleuder-cli does not!
266
267 ## Managing a list
268
269 To create and manage lists you have two options: schleuder-web and schleuder-cli.
270
271 Both require a running `schleuder-api-daemon`. Please see [the previous section](#schleuder-api) on how to set that up.
272
273
274 ### schleuder-web
275
276 To create lists with schleuder-web log in as `root@localhost`. Managing lists is allowed to each list-admin.
277
278 ### schleuder-cli
279
280 To use schleuder-cli please see the output of
281
282     schleuder-cli help
283
284 ## Maintenance
285
286 {: .note}
287 Please take care to have the following commands run by the user that owns the directory of schleuder lists (by default `/var/lib/schleuder/lists`) to avoid running into file permission problems!
288
289
290 Schleuder can **check all keys** that are present in the list's keyrings for (upcoming) expiration dates, revocation, or other reasons for not being usable.
291
292 Call this command weekly from cron to automate the check and have the results sent to the respective list-admins:
293
294     schleuder check_keys
295
296
297 Schleuder can also **refresh all keys** in the same manner. Each key of each list will be refreshed from a keyserver one by one. If you're using gpg 2.1, it's possible to configure a TOR onion service to be used as keyserver! See [the config](https://0xacab.org/schleuder/schleuder/blob/main/etc/schleuder.yml) for an example.
298
299
300 Call this command weekly from cron to automate the check and have the results sent to the respective list-admins:
301
302     schleuder refresh_keys
303
304 The available packages for Debian and CentOS both install a weekly cron job that check and refresh keys. Listadmins will be notified about issues with or changes to their keyring.
305
306 An additional maintenance command is available that allows you to pin subscriptions to their best matching key. If there is no key assigned, schleuder will try to select a key from the list's keyring that distinctly matches the subscription's email address.
307
308 This feature should be used with care. It's easy for a malicious (or inexperienced) person to inject additional user-IDs into the list's keyring. This can lead to situations in which people suddenly receive emails that are encrypted to a key they don't own.
309
310 You should better not run this command automatedly, and you should always examine the output closely to check for unintended consequences.
311
312     schleuder pin_keys
313
314
315 {% include participate.md %}
316