chiark / gitweb /
Various nips and tucks.
[tripe] / doc / tripe.8
1 .\" -*-nroff-*-
2 .\".
3 .de hP
4 .IP
5 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
6 ..
7 .de VS
8 .sp 1
9 .RS
10 .nf
11 .ft B
12 ..
13 .de VE
14 .ft R
15 .fi
16 .RE
17 .sp 1
18 ..
19 .ie t \{\
20 .  ds o \(bu
21 .  ds ss \s8\u
22 .  ds se \d\s0
23 .  if \n(.g \{\
24 .    fam P
25 .  \}
26 .\}
27 .el \{\
28 .  ds o o
29 .  ds ss ^
30 .  ds se
31 .\}
32 .TH tripe 8 "10 February 2001" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
33 .SH "NAME"
34 tripe \- a simple VPN daemon
35 .SH "SYNOPSIS"
36 .B tripe
37 .RB [ \-D ]
38 .RB [ \-d
39 .IR dir ]
40 .RB [ \-p
41 .IR port ]
42 .RB [ \-U
43 .IR user ]
44 .RB [ \-G
45 .IR group ]
46 .br
47         
48 .RB [ \-k
49 .IR priv-keyring ]
50 .RB [ \-K
51 .IR pub-keyring ]
52 .RB [ \-t
53 .IR key-tag ]
54 .br
55         
56 .RB [ \-a
57 .IR socket ]
58 .RB [ \-T
59 .IR trace-opts ]
60 .SH "DESCRIPTION"
61 The
62 .B tripe
63 program is a server which can provide strong IP-level encryption and
64 authentication between co-operating hosts.  The program and its protocol
65 are deliberately very simple, to make analysing them easy and to help
66 build trust rapidly in the system.
67 .SS "Overview"
68 The
69 .B tripe
70 server manages a number of secure connections to other `peer' hosts.
71 Each daemon is given a private key of its own, and a file of public keys
72 for the peers with which it is meant to communicate.  It is responsible
73 for negotiating sets of symmetric keys with its peers, and for
74 encrypting, encapsulating and sending IP packets to its peers, and
75 decrypting, checking and de-encapsulating packets it receives from
76 them.
77 .PP
78 When the server starts, it creates a Unix-domain socket on which it
79 listens for administration commands.  It also logs warnings and
80 diagnostic information to the programs connected to its admin socket.
81 Clients connected to the socket can add new peers, and remove or find
82 out about existing peers.  The textual protocol used to give the
83 .B tripe
84 server admin commands is described in
85 .BR tripe\-admin (5).
86 A client program
87 .BR tripectl (1)
88 is provided to allow commands to be sent to the server either
89 interactively or by simple scripts.
90 .SS "Command-line arguments"
91 If not given any command-line arguments,
92 .B tripe
93 will initialize by following these steps:
94 .hP 1.
95 It sets the directory named by the
96 .B TRIPEDIR
97 environment variable (or
98 .B /var/lib/tripe
99 if the variable is unset) as the current directory.
100 .hP 2.
101 It acquires a UDP socket with an arbitrary kernel-selected port number.
102 It will use this socket to send and receive all communications with its
103 peer servers.  The port chosen may be discovered by means of the
104 .B PORT
105 admin command (see
106 .BR tripe\-admin (5)).
107 .hP 3.
108 It loads the private key with the tag or type name
109 .B tripe\-dh
110 from the Catacomb-format file
111 .BR keyring ,
112 and loads the file
113 .B keyring.pub
114 ready for extracting the public keys of peers as they're introduced.
115 (The format of these files is described in
116 .BR keyring (5).
117 They are maintained using the program
118 .BR key (1)
119 provided with the Catacomb distribution.)
120 .hP 4.
121 It creates and listens to the Unix-domain socket
122 .BR tripesock .
123 .PP
124 Following this, the server enters its main loop, accepting admin
125 connections and obeying any administrative commands, and communicating
126 with peers.  It also treats its standard input and standard output
127 streams as an admin connection, reading commands from standard input and
128 writing responses and diagnostics messages to standard output.  Finally,
129 it will reload keys from its keyring files if it notices that they've
130 changed (it checks inode number and modification time) \- there's no
131 need to send a signal.
132 .PP
133 Much of this behaviour may be altered by giving
134 .B tripe
135 suitable command-line options:
136 .TP
137 .B "\-h, \-\-help"
138 Writes a brief description of the command-line options available to
139 standard output and exits with status 0.
140 .TP
141 .B "\-v, \-\-version"
142 Writes
143 .BR tripe 's
144 version number to standard output and exits with status 0.
145 .TP
146 .B "\-u, \-\-usage"
147 Writes a brief usage summary to standard output and exits with status 0.
148 .TP
149 .B "\-D, \-\-daemon"
150 Dissociates from its terminal and starts running in the background after
151 completing the initialization procedure described above.  If running as
152 a daemon,
153 .B tripe
154 will not read commands from standard input or write diagnostics to
155 standard output.  A better way to start
156 .B tripe
157 in the background is with
158 .BR tripectl (1).
159 .TP
160 .BI "\-d, \-\-directory=" dir
161 Makes
162 .I dir
163 the current directory, instead of
164 .BR /var/lib/tripe .
165 Give a current directory of
166 .B .
167 if you don't want it to change directory at all.
168 .TP
169 .BI "\-p, \-\-port=" port
170 Use the specified UDP port for all communications with peers, rather
171 than an arbitarary kernel-assigned port.
172 .TP
173 .BI "\-U, \-\-setuid=" user
174 Set uid to that of
175 .I user
176 (either a user name or integer uid) after initialization.  Also set gid
177 to
178 .IR user 's
179 primary group, unless overridden by a
180 .B \-G
181 option.
182 .TP
183 .BI "\-G, \-\-setgid=" group
184 Set gid to that of
185 .I group
186 (either a group name or integer gid) after initialization.
187 .TP
188 .BI "\-k, \-\-priv\-keyring=" file
189 Reads the private key from
190 .I file
191 rather than the default
192 .BR keyring .
193 .TP
194 .BI "\-K, \-\-pub\-keyring=" file
195 Reads public keys from
196 .I file
197 rather than the default
198 .BR keyring.pub .
199 This can be the same as the private keyring, but that's not recommended.
200 .TP
201 .BI "\-t, \-\-tag=" tag
202 Uses the private key whose tag or type is
203 .I tag
204 rather than the default
205 .BR tripe\-dh .
206 .TP
207 .BI "\-a, \-\-admin\-socket=" socket
208 Accept admin connections to a Unix-domain socket named
209 .I socket
210 rather than the default
211 .BR tripesock .
212 .TP
213 .BI "\-T, \-\-trace=" trace-opts
214 Allows the enabling or disabling of various internal diagnostics.  See
215 below for the list of options.
216 .SS "Setting up a VPN with tripe"
217 The
218 .B tripe
219 server identifies peers by name.  While it's
220 .I possible
221 for each host to maintain its own naming system for its peers, this is
222 likely to lead to confusion, and it's more sensible to organize a naming
223 system that works everywhere.  How you manage this naming is up to you.
224 The only restriction on the format of names is that they must be valid
225 Catacomb key tags, since this is how
226 .B tripe
227 identifies which public key to use for a particular peer: they may not
228 contain whitespace characters, or a colon
229 .RB ` : '
230 or dot
231 .RB ` . ',
232 .PP
233 Allocating IP addresses for VPNs can get quite complicated.  I'll
234 attempt to illustrate with a relatively simple example.  Our objective
235 will be to set up a virtual private network between two sites of
236 .BR example.com .
237 The two sites are using distinct IP address ranges from the private
238 address space described in RFC1918: site A is using addresses from
239 10.0.1.0/24 and site B is using 10.0.2.0/24.  Each site has a gateway
240 host set up with both an address on the site's private network, and an
241 externally-routable address from the public IP address space.  Site A's
242 gateway machine,
243 .BR alice ,
244 has the addresses 10.0.1.1 and 200.0.1.1; site B's gateway is
245 .B bob
246 and has addresses 10.0.2.1 and 200.0.2.1.
247 .PP
248 This isn't quite complicated enough.  Each of
249 .B alice
250 and
251 .B bob
252 needs an extra IP address which we'll use when setting up the
253 point-to-point link.  These addresses need to be routable, at least
254 within the virtual private network: unfortunately, you can't just use
255 the same pair everywhere.  We'll assign
256 .B alice
257 the point-to-point address 192.168.0.1, and
258 .B bob
259 the address 192.168.0.2.
260 .hP 1.
261 Install
262 .B tripe
263 on both of the gateway hosts.  Create the directory
264 .BR /var/lib/tripe .
265 .hP 2.
266 On
267 .BR alice ,
268 make
269 .B /var/lib/tripe
270 the current directory and generate a Diffie-Hellman group:
271 .RS
272 .VS
273 key add \-adh\-param \-LS \-b2048 \-B256 \e
274         \-eforever \-tparam tripe\-dh\-param
275 .VE
276 (See
277 .BR key (1)
278 from the Catacomb distribution for details about the
279 .B key
280 command.)  Also generate a private key for
281 .BR alice :
282 .VS
283 key add \-adh \-pparam \-talice \e
284         \-e"now + 1 year" tripe\-dh
285 .VE
286 Extract the group parameters and
287 .BR alice 's
288 public key to
289 .I separate
290 files, and put the public key in
291 .BR keyring.pub :
292 .VS
293 key extract param param
294 key extract \-f\-secret alice.pub alice
295 key \-kkeyring.pub merge alice.pub
296 .VE
297 Send the files
298 .B param
299 and
300 .B alice.pub
301 to
302 .B bob
303 in some secure way (e.g., in PGP-signed email, or by using SSH), so that
304 you can be sure they've not been altered in transit.
305 .RE
306 .hP 3.
307 On
308 .B bob
309 now, make
310 .B /var/lib/tripe
311 the current directory, and import the key material from
312 .BR alice :
313 .RS
314 .VS
315 key merge param
316 key \-kkeyring.pub merge alice.pub
317 .VE
318 Generate a private key for
319 .B bob
320 and extract the public half, as before:
321 .VS
322 key add \-adh \-pparam \-tbob \e
323         \-e"now + 1 year" tripe\-dh
324 key extract \-f\-secret bob.pub bob
325 key \-kkeyring.pub merge bob.pub
326 .VE
327 and send
328 .B bob.pub
329 back to
330 .B alice
331 using some secure method.
332 .RE
333 .hP 4
334 On
335 .BR alice ,
336 merge
337 .B bob 's
338 key into the public keyring.  Now, on each host, run
339 .RS
340 .VS
341 key \-kkeyring.pub fingerprint
342 .VE
343 and check that the hashes match.  If the two sites have separate
344 administrators, they should read the hashes to each other over the
345 telephone (assuming that they can recognize each other's voices).
346 .RE
347 .hP 5.
348 Start the
349 .B tripe
350 servers up.  Run
351 .RS
352 .VS
353 tripectl \-slD \-S\-P23169
354 .VE
355 on each of
356 .B alice
357 and
358 .BR bob .
359 (The
360 .RB ` \-P23169 '
361 forces the server to use UDP port 23169: use some other number if 23169
362 is inappropriate for your requirements.  I chose it by reducing the
363 RIPEMD160 hash of
364 .RB ` tripe\-port\-number\e0 '
365 modulo 2\*(ss16\*(se.)
366 .RE
367 .hP 6.
368 To get
369 .B alice
370 talking to
371 .BR bob ,
372 run this shell script (or one like it):
373 .RS
374 .VS
375 #! /bin/sh
376
377 tripectl add bob 200.0.2.1 23169
378 ifname=`tripectl ifname bob`
379 ifconfig $ifname \e
380         192.168.0.1 \e
381         pointopoint 192.168.0.2
382 route add -net \e
383         10.0.2.0 netmask 255.255.255.0 \e
384         gw 192.168.0.2
385 .VE
386 Read
387 .BR ifconfig (8)
388 and
389 .BR route (8)
390 to find out about your system's variants of these commands.  The
391 versions shown above assume a Linux system.
392 Run a similar script on
393 .BR bob ,
394 to tell its
395 .B tripe
396 server to talk to
397 .BR alice .
398 .RE
399 .hP 7.
400 Congratulations.  The two servers will exchange keys and begin sending
401 packets almost immediately.  You've set up a virtual private network.
402 .SS "About the name"
403 The program's name is
404 .BR tripe ,
405 all in lower-case.  The name of the protocol it uses is `TrIPE', with
406 four capital letters and one lower-case.  The name stands for `Trivial
407 IP Encryption'.
408 .SH "BUGS"
409 The code hasn't been audited.  It may contain security bugs.  If you
410 find one, please inform the author
411 .IR immediately .
412 .SH "SEE ALSO"
413 .BR key (1),
414 .BR tripectl (1),
415 .BR tripe\-admin (5).
416 .PP
417 .IR "The Trivial IP Encryption Protocol" ,
418 .IR "The Wrestlers Protocol" .
419 .SH "AUTHOR"
420 Mark Wooding, <mdw@nsict.org>