chiark / gitweb /
server/admin.c (a_init): Abort if we can't set socket permissions.
[tripe] / server / tripe.8.in
CommitLineData
74eb47db 1.\" -*-nroff-*-
2.\".
fc916a09
MW
3.\" Manual for the server
4.\"
5.\" (c) 2008 Straylight/Edgeware
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This file is part of Trivial IP Encryption (TrIPE).
11.\"
12.\" TrIPE is free software; you can redistribute it and/or modify
13.\" it under the terms of the GNU General Public License as published by
14.\" the Free Software Foundation; either version 2 of the License, or
15.\" (at your option) any later version.
16.\"
17.\" TrIPE is distributed in the hope that it will be useful,
18.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
19.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20.\" GNU General Public License for more details.
21.\"
22.\" You should have received a copy of the GNU General Public License
23.\" along with TrIPE; if not, write to the Free Software Foundation,
24.\" Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25.
26.\"--------------------------------------------------------------------------
e99aedcf 27.so ../common/defs.man \" @@@PRE@@@
fc916a09
MW
28.
29.\"--------------------------------------------------------------------------
74eb47db 30.TH tripe 8 "10 February 2001" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
fc916a09
MW
31.
32.\"--------------------------------------------------------------------------
74eb47db 33.SH "NAME"
fc916a09 34.
74eb47db 35tripe \- a simple VPN daemon
fc916a09
MW
36.
37.\"--------------------------------------------------------------------------
74eb47db 38.SH "SYNOPSIS"
fc916a09 39.
74eb47db 40.B tripe
46dde080 41.RB [ \-DF ]
74eb47db 42.RB [ \-d
43.IR dir ]
d13e5724 44.RB [ \-b
45.IR addr ]
33ced0d3 46.RB [ \-p
47.IR port ]
42da2a58 48.RB [ \-n
49.IR tunnel ]
d13e5724 50.br
85b1ebd6 51 \c
33ced0d3 52.RB [ \-U
53.IR user ]
54.RB [ \-G
55.IR group ]
d13e5724 56.RB [ \-a
57.IR socket ]
58.RB [ \-T
59.IR trace-opts ]
74eb47db 60.br
85b1ebd6 61 \c
74eb47db 62.RB [ \-k
63.IR priv-keyring ]
64.RB [ \-K
65.IR pub-keyring ]
66.RB [ \-t
67.IR key-tag ]
fc916a09
MW
68.
69.\"--------------------------------------------------------------------------
74eb47db 70.SH "DESCRIPTION"
fc916a09 71.
74eb47db 72The
73.B tripe
74program is a server which can provide strong IP-level encryption and
1a19f865 75authentication between co-operating hosts. The program and its protocol
76are deliberately very simple, to make analysing them easy and to help
77build trust rapidly in the system.
74eb47db 78.SS "Overview"
79The
80.B tripe
81server manages a number of secure connections to other `peer' hosts.
82Each daemon is given a private key of its own, and a file of public keys
83for the peers with which it is meant to communicate. It is responsible
84for negotiating sets of symmetric keys with its peers, and for
85encrypting, encapsulating and sending IP packets to its peers, and
86decrypting, checking and de-encapsulating packets it receives from
87them.
88.PP
89When the server starts, it creates a Unix-domain socket on which it
90listens for administration commands. It also logs warnings and
91diagnostic information to the programs connected to its admin socket.
92Clients connected to the socket can add new peers, and remove or find
93out about existing peers. The textual protocol used to give the
94.B tripe
95server admin commands is described in
96.BR tripe\-admin (5).
97A client program
98.BR tripectl (1)
99is provided to allow commands to be sent to the server either
100interactively or by simple scripts.
101.SS "Command-line arguments"
102If not given any command-line arguments,
103.B tripe
104will initialize by following these steps:
1a19f865 105.hP 1.
106It sets the directory named by the
107.B TRIPEDIR
108environment variable (or
f7b5d108 109.B "\*(/c"
1a19f865 110if the variable is unset) as the current directory.
111.hP 2.
74eb47db 112It acquires a UDP socket with an arbitrary kernel-selected port number.
113It will use this socket to send and receive all communications with its
114peer servers. The port chosen may be discovered by means of the
115.B PORT
116admin command (see
117.BR tripe\-admin (5)).
1a19f865 118.hP 3.
74eb47db 119It loads the private key with the tag or type name
fc5f4823
MW
120.B tripe
121(or, failing that,
74eb47db 122.B tripe\-dh
fc5f4823 123for backwards compatibility reasons) from the Catacomb-format file
74eb47db 124.BR keyring ,
125and loads the file
126.B keyring.pub
127ready for extracting the public keys of peers as they're introduced.
128(The format of these files is described in
129.BR keyring (5).
130They are maintained using the program
131.BR key (1)
132provided with the Catacomb distribution.)
1a19f865 133.hP 4.
74eb47db 134It creates and listens to the Unix-domain socket
135.BR tripesock .
136.PP
137Following this, the server enters its main loop, accepting admin
138connections and obeying any administrative commands, and communicating
139with peers. It also treats its standard input and standard output
140streams as an admin connection, reading commands from standard input and
33ced0d3 141writing responses and diagnostics messages to standard output. Finally,
142it will reload keys from its keyring files if it notices that they've
143changed (it checks inode number and modification time) \- there's no
144need to send a signal.
74eb47db 145.PP
146Much of this behaviour may be altered by giving
147.B tripe
148suitable command-line options:
149.TP
150.B "\-h, \-\-help"
151Writes a brief description of the command-line options available to
152standard output and exits with status 0.
153.TP
154.B "\-v, \-\-version"
155Writes
156.BR tripe 's
157version number to standard output and exits with status 0.
158.TP
159.B "\-u, \-\-usage"
160Writes a brief usage summary to standard output and exits with status 0.
161.TP
42da2a58 162.B "\-\-tunnels"
163Writes to standard output a list of the configured tunnel drivers, one
164per line, and exits with status 0. This is intended for the use of the
3cdc3f3a 165start-up script, so that it can check that it will actually work.
166.TP
74eb47db 167.B "\-D, \-\-daemon"
168Dissociates from its terminal and starts running in the background after
169completing the initialization procedure described above. If running as
170a daemon,
171.B tripe
172will not read commands from standard input or write diagnostics to
173standard output. A better way to start
174.B tripe
175in the background is with
176.BR tripectl (1).
177.TP
46dde080
MW
178.B "\-F, \-\-foreground"
179Runs the server in the `foreground'; i.e.,
180.B tripe
181will quit if it sees end-of-file on its standard input. This is
182incompatible with
183.BR \-D .
184.TP
74eb47db 185.BI "\-d, \-\-directory=" dir
186Makes
187.I dir
797cf76b
MW
188the current directory. The default directory to change to is given by
189the environment variable
190.BR TRIPEDIR ;
191if that's not specified, a default default of
f7b5d108 192.B "\*(/c"
797cf76b 193is used. Give a current directory of
74eb47db 194.B .
195if you don't want it to change directory at all.
196.TP
d13e5724 197.BI "\-b, \-\-bind-address="addr
198Bind the UDP socket to IP address
199.I addr
200rather than the default of
201.BR INADDR_ANY .
202This is useful if your main globally-routable IP address is one you want
203to tunnel through the VPN.
204.TP
74eb47db 205.BI "\-p, \-\-port=" port
206Use the specified UDP port for all communications with peers, rather
207than an arbitarary kernel-assigned port.
208.TP
42da2a58 209.BI "\-n, \-\-tunnel=" tunnel
210Use the specified tunnel driver for new peers by default.
211.TP
33ced0d3 212.BI "\-U, \-\-setuid=" user
213Set uid to that of
214.I user
215(either a user name or integer uid) after initialization. Also set gid
216to
217.IR user 's
218primary group, unless overridden by a
219.B \-G
aa2405e8
MW
220option. The selected user (and group) will also be the owner of the
221administration socket.
33ced0d3 222.TP
223.BI "\-G, \-\-setgid=" group
224Set gid to that of
225.I group
226(either a group name or integer gid) after initialization.
227.TP
74eb47db 228.BI "\-k, \-\-priv\-keyring=" file
229Reads the private key from
230.I file
231rather than the default
232.BR keyring .
233.TP
234.BI "\-K, \-\-pub\-keyring=" file
235Reads public keys from
236.I file
237rather than the default
238.BR keyring.pub .
239This can be the same as the private keyring, but that's not recommended.
240.TP
241.BI "\-t, \-\-tag=" tag
242Uses the private key whose tag or type is
243.I tag
244rather than the default
fc5f4823
MW
245.B tripe
246or
74eb47db 247.BR tripe\-dh .
248.TP
249.BI "\-a, \-\-admin\-socket=" socket
250Accept admin connections to a Unix-domain socket named
797cf76b
MW
251.IR socket .
252The default socket, if this option isn't specified, is given by the
253environment variable
254.BR TRIPESOCK ;
255if that's not set either, then a default default of
f7b5d108 256.B "\*(/s/tripesock"
797cf76b 257is used instead.
74eb47db 258.TP
259.BI "\-T, \-\-trace=" trace-opts
260Allows the enabling or disabling of various internal diagnostics. See
261below for the list of options.
fc5f4823 262.SS "Key exchange group types"
d6623498 263The
264.B tripe
fc5f4823
MW
265server uses Diffie\(en\&Hellman key exchange to agree the symmetric keys
266used for bulk data transfer. Currently
d6623498 267.B tripe
fc5f4823
MW
268can do Diffie\(en\&Hellman in two different kinds of cyclic groups:
269.I "Schnorr groups"
270(denoted
271.BR dh )
272and
273.I "elliptic curve groups"
274(denoted
275.BR ec ).
d6623498 276.PP
fc5f4823
MW
277A Schnorr group is a prime-order subgroup of the multiplicative group of
278a finite field; this is the usual
279.I g\*(ssx\*(se
280mod
281.I p
282kind of Diffie\(en\&Hellman. An elliptic curve group is a prime-order
283subgroup of the abelian group of
284.BR K -rational
285points on an elliptic curve defined over a finite field
286.BR K .
287.PP
288Given current public knowledge, elliptic curves can provide similar or
289better security to systems based on integer discrete log problems,
290faster, and with less transmitted data. It's a matter of controversy
291whether this will continue to be the case. The author uses elliptic
292curves.
293.PP
294The server works out which it should be doing based on the key's
295.B kx-group
296attribute, which should be either
297.B dh
298or
299.BR ec .
300If this attribute isn't present, then the key's type is examined: if
301it's of the form
302.BR tripe\- group
303then the
304.I group
305is used. If no group is specified,
306.B dh
307is used as a fallback.
308.PP
309To create usual Schnorr-group keys, say something like
74eb47db 310.VS
fc5f4823
MW
311key add \-adh-param \-LS \-b3072 \-B256 \e
312 \-eforever \-tparam tripe\-param kx-group=dh
74eb47db 313.VE
fc5f4823 314to construct a parameters key; and create the private keys by
d6623498 315.VS
316key add \-adh \-pparam \-talice \e
fc5f4823 317 \-e"now + 1 year" tripe
d6623498 318.VE
fc5f4823 319To create elliptic curve keys, say something like
d6623498 320.VS
fc5f4823
MW
321key add \-aec\-param \-Cnist-p256 \-eforever \e
322 \-tparam tripe\-param kx-group=ec
52c03a2a 323.VE
324to construct a parameters key, using your preferred elliptic curve in
325the
326.B \-C
327option (see
328.BR key (1)
329for details); and create the private keys by
330.VS
331key add \-aec \-pparam \-talice \e
fc5f4823 332 \-e"now + 1 year" tripe
52c03a2a 333.VE
fc5f4823
MW
334Note that the
335.BR tripe-keys (8)
336program provides a rather more convenient means for generating and
337managing keys for
338.BR tripe .
b5c45da1 339.SS "Using other symmetric algorithms"
340The default symmetric algorithms
341.B tripe
342uses are Blowfish (by Schneier) for symmetric encryption, and RIPEMD-160
343(by Dobbertin, Bosselaers and Preneel) for hashing and as a MAC (in HMAC
344mode, designed by Bellare, Canetti and Krawczyk). These can all be
345overridden by setting attributes on your private key, as follows.
346.TP
347.B cipher
348Names the symmetric encryption scheme to use. The default is
349.BR blowfish\-cbc .
350.TP
351.B hash
352Names the hash function to use. The default is
353.BR rmd160 .
354.TP
355.B mac
356Names the message authentication code to use. The name of the MAC may
357be followed by a
358.RB ` / '
359and the desired tag length in bits. The default is
360.IB hash \-hmac
361at half the underlying hash function's output length.
362.TP
363.B mgf
364A `mask-generation function', used in the key-exchange. The default is
365.IB hash \-mgf
366and there's no good reason to change it.
b9066fbb 367.SS "Using SLIP interfaces"
368Though not for the faint of heart, it is possible to get
369.B tripe
370to read and write network packets to a pair of file descriptors using
371SLIP encapsulation. No fancy header compression of any kind is
98fdb08d 372supported.
373.PP
374Two usage modes are supported: a preallocation system, whereby SLIP
375interfaces are created and passed to the
376.B tripe
377server at startup; and a dynamic system, where the server runs a script
378to allocate a new SLIP interface when it needs one. It is possible to
379use a mixture of these two modes, starting
b9066fbb 380.B tripe
98fdb08d 381with a few preallocated interfaces and having it allocate more
382dynamically as it needs them.
383.PP
384The behaviour of
385.BR tripe 's
386SLIP driver is controlled by the
387.B TRIPE_SLIPIF
1f68dfc5 388environment variable. The server will not create SLIP tunnels if this
389variable is not defined. The variable's value is a colon-delimited list
390of preallocated interfaces, followed optionally by the filename of a
391script to run to dynamically allocate more interfaces.
b9066fbb 392.PP
98fdb08d 393A static allocation entry has the form
b9066fbb 394.IR infd [ \c
395.BI , outfd \c
396.RB ] \c
397.BI = \c
98fdb08d 398.IR ifname ,
b9066fbb 399If the
400.I outfd
401is omitted, the same file descriptor is used for input and output.
402.PP
98fdb08d 403The dynamic allocation script must be named by an absolute or relative
e04c2d50 404pathname, beginning with
98fdb08d 405.RB ` / '
406or
407.RB ` . '.
408The server will pass the script an argument, which is the name of the
409peer for which the interface is being created. The script should
410allocate a new SLIP interface (presumably by creating a pty pair),
411configure it appropriately, and write the interface's name to its
412standard output, followed by a newline. It should then read and write
413SLIP packets on its stdin and stdout. The script's stdin will be closed
414when the interface is no longer needed, and the server will attempt to
415send it a
416.B SIGTERM
417signal (though this may fail if the script runs with higher privileges
418than the server).
419.PP
b9066fbb 420The output file descriptor should not block unless it really needs to:
421the
422.B tripe
1f68dfc5 423daemon assumes that it won't, and will get wedged waiting for it to
424accept output.
74eb47db 425.SS "About the name"
426The program's name is
427.BR tripe ,
428all in lower-case. The name of the protocol it uses is `TrIPE', with
429four capital letters and one lower-case. The name stands for `Trivial
430IP Encryption'.
fc916a09
MW
431.
432.\"--------------------------------------------------------------------------
74eb47db 433.SH "BUGS"
fc916a09 434.
74eb47db 435The code hasn't been audited. It may contain security bugs. If you
436find one, please inform the author
437.IR immediately .
fc916a09
MW
438.
439.\"--------------------------------------------------------------------------
74eb47db 440.SH "SEE ALSO"
fc916a09 441.
74eb47db 442.BR key (1),
443.BR tripectl (1),
fc5f4823
MW
444.BR tripe\-admin (5),
445.BR tripe\-keys (8).
74eb47db 446.PP
447.IR "The Trivial IP Encryption Protocol" ,
448.IR "The Wrestlers Protocol" .
fc916a09
MW
449.
450.\"--------------------------------------------------------------------------
74eb47db 451.SH "AUTHOR"
fc916a09 452.
d36eda2a 453Mark Wooding, <mdw@distorted.org.uk>
fc916a09
MW
454.
455.\"----- That's all, folks --------------------------------------------------