chiark / gitweb /
tripe.h: Make job index be unsigned int, not unsigned short.
[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.\"--------------------------------------------------------------------------
27.so ../defs.man.in \" @@@PRE@@@
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
41.RB [ \-D ]
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
fc916a09 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
120.B tripe\-dh
121from the Catacomb-format file
122.BR keyring ,
123and loads the file
124.B keyring.pub
125ready for extracting the public keys of peers as they're introduced.
126(The format of these files is described in
127.BR keyring (5).
128They are maintained using the program
129.BR key (1)
130provided with the Catacomb distribution.)
1a19f865 131.hP 4.
74eb47db 132It creates and listens to the Unix-domain socket
133.BR tripesock .
134.PP
135Following this, the server enters its main loop, accepting admin
136connections and obeying any administrative commands, and communicating
137with peers. It also treats its standard input and standard output
138streams as an admin connection, reading commands from standard input and
33ced0d3 139writing responses and diagnostics messages to standard output. Finally,
140it will reload keys from its keyring files if it notices that they've
141changed (it checks inode number and modification time) \- there's no
142need to send a signal.
74eb47db 143.PP
144Much of this behaviour may be altered by giving
145.B tripe
146suitable command-line options:
147.TP
148.B "\-h, \-\-help"
149Writes a brief description of the command-line options available to
150standard output and exits with status 0.
151.TP
152.B "\-v, \-\-version"
153Writes
154.BR tripe 's
155version number to standard output and exits with status 0.
156.TP
157.B "\-u, \-\-usage"
158Writes a brief usage summary to standard output and exits with status 0.
159.TP
42da2a58 160.B "\-\-tunnels"
161Writes to standard output a list of the configured tunnel drivers, one
162per line, and exits with status 0. This is intended for the use of the
3cdc3f3a 163start-up script, so that it can check that it will actually work.
164.TP
74eb47db 165.B "\-D, \-\-daemon"
166Dissociates from its terminal and starts running in the background after
167completing the initialization procedure described above. If running as
168a daemon,
169.B tripe
170will not read commands from standard input or write diagnostics to
171standard output. A better way to start
172.B tripe
173in the background is with
174.BR tripectl (1).
175.TP
176.BI "\-d, \-\-directory=" dir
177Makes
178.I dir
797cf76b
MW
179the current directory. The default directory to change to is given by
180the environment variable
181.BR TRIPEDIR ;
182if that's not specified, a default default of
fc916a09 183.B "*(/c"
797cf76b 184is used. Give a current directory of
74eb47db 185.B .
186if you don't want it to change directory at all.
187.TP
d13e5724 188.BI "\-b, \-\-bind-address="addr
189Bind the UDP socket to IP address
190.I addr
191rather than the default of
192.BR INADDR_ANY .
193This is useful if your main globally-routable IP address is one you want
194to tunnel through the VPN.
195.TP
74eb47db 196.BI "\-p, \-\-port=" port
197Use the specified UDP port for all communications with peers, rather
198than an arbitarary kernel-assigned port.
199.TP
42da2a58 200.BI "\-n, \-\-tunnel=" tunnel
201Use the specified tunnel driver for new peers by default.
202.TP
33ced0d3 203.BI "\-U, \-\-setuid=" user
204Set uid to that of
205.I user
206(either a user name or integer uid) after initialization. Also set gid
207to
208.IR user 's
209primary group, unless overridden by a
210.B \-G
211option.
212.TP
213.BI "\-G, \-\-setgid=" group
214Set gid to that of
215.I group
216(either a group name or integer gid) after initialization.
217.TP
74eb47db 218.BI "\-k, \-\-priv\-keyring=" file
219Reads the private key from
220.I file
221rather than the default
222.BR keyring .
223.TP
224.BI "\-K, \-\-pub\-keyring=" file
225Reads public keys from
226.I file
227rather than the default
228.BR keyring.pub .
229This can be the same as the private keyring, but that's not recommended.
230.TP
231.BI "\-t, \-\-tag=" tag
232Uses the private key whose tag or type is
233.I tag
234rather than the default
235.BR tripe\-dh .
236.TP
237.BI "\-a, \-\-admin\-socket=" socket
238Accept admin connections to a Unix-domain socket named
797cf76b
MW
239.IR socket .
240The default socket, if this option isn't specified, is given by the
241environment variable
242.BR TRIPESOCK ;
243if that's not set either, then a default default of
fc916a09 244.B "*(/s/tripesock"
797cf76b 245is used instead.
74eb47db 246.TP
247.BI "\-T, \-\-trace=" trace-opts
248Allows the enabling or disabling of various internal diagnostics. See
249below for the list of options.
d6623498 250.SS "Setting up a VPN with tripe"
251The
252.B tripe
253server identifies peers by name. While it's
254.I possible
255for each host to maintain its own naming system for its peers, this is
256likely to lead to confusion, and it's more sensible to organize a naming
257system that works everywhere. How you manage this naming is up to you.
258The only restriction on the format of names is that they must be valid
259Catacomb key tags, since this is how
260.B tripe
261identifies which public key to use for a particular peer: they may not
262contain whitespace characters, or a colon
263.RB ` : '
264or dot
265.RB ` . ',
266.PP
267Allocating IP addresses for VPNs can get quite complicated. I'll
268attempt to illustrate with a relatively simple example. Our objective
269will be to set up a virtual private network between two sites of
270.BR example.com .
271The two sites are using distinct IP address ranges from the private
272address space described in RFC1918: site A is using addresses from
27310.0.1.0/24 and site B is using 10.0.2.0/24. Each site has a gateway
274host set up with both an address on the site's private network, and an
275externally-routable address from the public IP address space. Site A's
276gateway machine,
277.BR alice ,
278has the addresses 10.0.1.1 and 200.0.1.1; site B's gateway is
279.B bob
280and has addresses 10.0.2.1 and 200.0.2.1.
d6623498 281.hP 1.
282Install
283.B tripe
284on both of the gateway hosts. Create the directory
285.BR /var/lib/tripe .
286.hP 2.
287On
288.BR alice ,
289make
290.B /var/lib/tripe
291the current directory and generate a Diffie-Hellman group:
292.RS
74eb47db 293.VS
294key add \-adh\-param \-LS \-b2048 \-B256 \e
295 \-eforever \-tparam tripe\-dh\-param
296.VE
d6623498 297(See
298.BR key (1)
299from the Catacomb distribution for details about the
300.B key
301command.) Also generate a private key for
302.BR alice :
303.VS
304key add \-adh \-pparam \-talice \e
305 \-e"now + 1 year" tripe\-dh
306.VE
307Extract the group parameters and
308.BR alice 's
309public key to
310.I separate
311files, and put the public key in
312.BR keyring.pub :
74eb47db 313.VS
314key extract param param
37075862 315key extract \-f\-secret alice.pub alice
d6623498 316key \-kkeyring.pub merge alice.pub
74eb47db 317.VE
d6623498 318Send the files
319.B param
320and
321.B alice.pub
322to
323.B bob
324in some secure way (e.g., in PGP-signed email, or by using SSH), so that
325you can be sure they've not been altered in transit.
326.RE
327.hP 3.
328On
329.B bob
330now, make
331.B /var/lib/tripe
332the current directory, and import the key material from
333.BR alice :
334.RS
74eb47db 335.VS
336key merge param
d6623498 337key \-kkeyring.pub merge alice.pub
74eb47db 338.VE
d6623498 339Generate a private key for
340.B bob
341and extract the public half, as before:
74eb47db 342.VS
d6623498 343key add \-adh \-pparam \-tbob \e
344 \-e"now + 1 year" tripe\-dh
383f2a0b 345key extract \-f\-secret bob.pub bob
d6623498 346key \-kkeyring.pub merge bob.pub
74eb47db 347.VE
d6623498 348and send
349.B bob.pub
350back to
351.B alice
352using some secure method.
353.RE
354.hP 4
355On
356.BR alice ,
357merge
358.B bob 's
359key into the public keyring. Now, on each host, run
360.RS
361.VS
362key \-kkeyring.pub fingerprint
363.VE
364and check that the hashes match. If the two sites have separate
365administrators, they should read the hashes to each other over the
366telephone (assuming that they can recognize each other's voices).
367.RE
368.hP 5.
369Start the
370.B tripe
371servers up. Run
372.RS
373.VS
165efde7 374tripectl \-slD
d6623498 375.VE
376on each of
377.B alice
378and
379.BR bob .
d6623498 380.RE
381.hP 6.
382To get
383.B alice
384talking to
385.BR bob ,
386run this shell script (or one like it):
387.RS
388.VS
389#! /bin/sh
74eb47db 390
165efde7 391tripectl add bob 200.0.2.1 4070
d6623498 392ifname=`tripectl ifname bob`
1f68dfc5 393ifconfig $ifname 10.0.1.1 pointopoint 10.0.2.1
d6623498 394route add -net \e
395 10.0.2.0 netmask 255.255.255.0 \e
1f68dfc5 396 gw 10.0.2.1
d6623498 397.VE
398Read
399.BR ifconfig (8)
400and
401.BR route (8)
402to find out about your system's variants of these commands. The
403versions shown above assume a Linux system.
404Run a similar script on
405.BR bob ,
406to tell its
407.B tripe
408server to talk to
409.BR alice .
410.RE
411.hP 7.
412Congratulations. The two servers will exchange keys and begin sending
413packets almost immediately. You've set up a virtual private network.
52c03a2a 414.SS "Using elliptic curve keys"
415The
416.B tripe
417server can use elliptic curve Diffie-Hellman for key exchange, rather
418than traditional integer Diffie-Hellman. Given current public
419knowledge, elliptic curves can provide similar or better security to
420systems based on integer discrete log problems, faster, and with less
421transmitted data. It's a matter of controversy whether this will
422continue to be the case. The author uses elliptic curves.
423.PP
424The server works out which it
425should be doing based on the key type, which is either
426.B tripe\-dh
427for standard Diffie-Hellman, or
428.B tripe\-ec
429for elliptic curves. To create elliptic curve keys, say something like
430.VS
431key add \-aec\-param \-Cnist-p192 \-eforever \e
432 \-tparam tripe\-ec\-param
433.VE
434to construct a parameters key, using your preferred elliptic curve in
435the
436.B \-C
437option (see
438.BR key (1)
439for details); and create the private keys by
440.VS
441key add \-aec \-pparam \-talice \e
442 \-e"now + 1 year" tripe\-ec
443.VE
444Now start
445.B tripe
446with the
447.B \-ttripe\-ec
448option, and all should be well.
b5c45da1 449.SS "Using other symmetric algorithms"
450The default symmetric algorithms
451.B tripe
452uses are Blowfish (by Schneier) for symmetric encryption, and RIPEMD-160
453(by Dobbertin, Bosselaers and Preneel) for hashing and as a MAC (in HMAC
454mode, designed by Bellare, Canetti and Krawczyk). These can all be
455overridden by setting attributes on your private key, as follows.
456.TP
457.B cipher
458Names the symmetric encryption scheme to use. The default is
459.BR blowfish\-cbc .
460.TP
461.B hash
462Names the hash function to use. The default is
463.BR rmd160 .
464.TP
465.B mac
466Names the message authentication code to use. The name of the MAC may
467be followed by a
468.RB ` / '
469and the desired tag length in bits. The default is
470.IB hash \-hmac
471at half the underlying hash function's output length.
472.TP
473.B mgf
474A `mask-generation function', used in the key-exchange. The default is
475.IB hash \-mgf
476and there's no good reason to change it.
b9066fbb 477.SS "Using SLIP interfaces"
478Though not for the faint of heart, it is possible to get
479.B tripe
480to read and write network packets to a pair of file descriptors using
481SLIP encapsulation. No fancy header compression of any kind is
98fdb08d 482supported.
483.PP
484Two usage modes are supported: a preallocation system, whereby SLIP
485interfaces are created and passed to the
486.B tripe
487server at startup; and a dynamic system, where the server runs a script
488to allocate a new SLIP interface when it needs one. It is possible to
489use a mixture of these two modes, starting
b9066fbb 490.B tripe
98fdb08d 491with a few preallocated interfaces and having it allocate more
492dynamically as it needs them.
493.PP
494The behaviour of
495.BR tripe 's
496SLIP driver is controlled by the
497.B TRIPE_SLIPIF
1f68dfc5 498environment variable. The server will not create SLIP tunnels if this
499variable is not defined. The variable's value is a colon-delimited list
500of preallocated interfaces, followed optionally by the filename of a
501script to run to dynamically allocate more interfaces.
b9066fbb 502.PP
98fdb08d 503A static allocation entry has the form
b9066fbb 504.IR infd [ \c
505.BI , outfd \c
506.RB ] \c
507.BI = \c
98fdb08d 508.IR ifname ,
b9066fbb 509If the
510.I outfd
511is omitted, the same file descriptor is used for input and output.
512.PP
98fdb08d 513The dynamic allocation script must be named by an absolute or relative
e04c2d50 514pathname, beginning with
98fdb08d 515.RB ` / '
516or
517.RB ` . '.
518The server will pass the script an argument, which is the name of the
519peer for which the interface is being created. The script should
520allocate a new SLIP interface (presumably by creating a pty pair),
521configure it appropriately, and write the interface's name to its
522standard output, followed by a newline. It should then read and write
523SLIP packets on its stdin and stdout. The script's stdin will be closed
524when the interface is no longer needed, and the server will attempt to
525send it a
526.B SIGTERM
527signal (though this may fail if the script runs with higher privileges
528than the server).
529.PP
b9066fbb 530The output file descriptor should not block unless it really needs to:
531the
532.B tripe
1f68dfc5 533daemon assumes that it won't, and will get wedged waiting for it to
534accept output.
74eb47db 535.SS "About the name"
536The program's name is
537.BR tripe ,
538all in lower-case. The name of the protocol it uses is `TrIPE', with
539four capital letters and one lower-case. The name stands for `Trivial
540IP Encryption'.
fc916a09
MW
541.
542.\"--------------------------------------------------------------------------
74eb47db 543.SH "BUGS"
fc916a09 544.
74eb47db 545The code hasn't been audited. It may contain security bugs. If you
546find one, please inform the author
547.IR immediately .
fc916a09
MW
548.
549.\"--------------------------------------------------------------------------
74eb47db 550.SH "SEE ALSO"
fc916a09 551.
74eb47db 552.BR key (1),
553.BR tripectl (1),
554.BR tripe\-admin (5).
555.PP
556.IR "The Trivial IP Encryption Protocol" ,
557.IR "The Wrestlers Protocol" .
fc916a09
MW
558.
559.\"--------------------------------------------------------------------------
74eb47db 560.SH "AUTHOR"
fc916a09 561.
d36eda2a 562Mark Wooding, <mdw@distorted.org.uk>
fc916a09
MW
563.
564.\"----- That's all, folks --------------------------------------------------