xref: /illumos-gate/usr/src/man/man8/tcpkey.8 (revision 7655c6d53c36750b508636f48c73a2de57754e5a)
1.\"
2.\" The contents of this file are subject to the terms of the Common
3.\" Development and Distribution License (the "License").  You may not use
4.\" this file except in compliance with the License.
5.\"
6.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or
7.\" http://www.opensolaris.org/os/licensing.  See the License for the
8.\" specific language governing permissions and limitations under the
9.\" License.
10.\"
11.\" When distributing Covered Code, include this CDDL HEADER in each file
12.\" and include the License file at usr/src/OPENSOLARIS.LICENSE.  If
13.\" applicable, add the following below this CDDL HEADER, with the fields
14.\" enclosed by brackets "[]" replaced with your own identifying
15.\" information: Portions Copyright [yyyy] [name of copyright owner]
16.\"
17.\" Copyright (C) 2008, Sun Microsystems, Inc. All Rights Reserved
18.\" Copyright 2024 Oxide Computer Company
19.\"
20.Dd August 14, 2024
21.Dt TCPKEY 8
22.Os
23.Sh NAME
24.Nm tcpkey
25.Nd Manages the Security Association Database (SADB) for TCP
26.Sh SYNOPSIS
27.Nm
28.Op Fl nvp
29.Nm
30.Op Fl nvp
31.Fl f Ar filename
32.Nm
33.Fl c Ar filename
34.Nm
35.Op Fl nvp
36.Cm get
37.Brq Ar Extension value Ns No \&...
38.Nm
39.Op Fl nvp
40.Cm delete
41.Brq Ar Extension value Ns No \&...
42.Nm
43.Op Fl nvp
44.Cm flush
45.Nm
46.Op Fl nvp
47.Cm dump
48.Nm
49.Op Fl nvp
50.Cm save
51.Op Ar filename
52.Sh DESCRIPTION
53The
54.Nm
55command is used to manually manipulate the
56.Xr tcp 4P
57security association
58.Pq SA
59database.
60.Pp
61TCP SAs are in one of three states:
62.Bl -tag -width indent
63.It Sy mature
64A newly added SA starts in the mature state and will remain there unless it
65is configured with any limits on its lifetime.
66.It Sy dying
67A mature SA which exceeds a soft lifetime limit will transition into the
68.Sy dying
69state.
70This state is informational only; the SA can continue to be used.
71A
72.Sy dying
73SA can be moved back to the
74.Sy mature
75state by updating its lifetime limits via the
76.Ic update
77command, so that they are no longer exceeded.
78A
79.Sy dying
80SA will transition to
81.Sy dead
82and be removed when it is either deleted via a
83.Ic delete
84or
85.Ic flush
86command, or subsequently exceeds a hard lifetime limit.
87.It Sy dead
88An SA which exceeds a hard lifetime limit will transition into the
89.Sy dead
90state, be unavailable for use on any new connections, and be removed from the
91system as soon as it is no longer used by any established TCP session.
92.El
93.Pp
94While the
95.Nm
96utility has only a limited number of general options, it supports a rich
97command language.
98The user may specify requests to be delivered by means of a programmatic
99interface specific for manual keying.
100See
101.Xr pf_key 4P .
102When
103.Nm
104is invoked with no arguments, it will enter an interactive mode which prints a
105prompt
106.Pq Dq tcpkey>
107to the standard output and accepts commands from the standard input until the
108end-of-file is reached.
109.Pp
110.Nm
111uses a
112.Xr pf_key 4P
113socket and the message types
114.Dv SADB_ADD ,
115.Dv SADB_UPDATE ,
116.Dv SADB_DELETE ,
117.Dv SADB_GET
118and
119.Dv SADB_FLUSH .
120Thus, you must have the
121.Dv PRIV_SYS_IP_CONFIG
122privilege to use this command.
123.Sh OPTIONS
124.Bl -tag -width Ds
125.It Fl c Op Ar filename
126Analogous to the
127.Fl f
128option
129.Pq see following ,
130except that the input is not executed but only checked for syntactical
131correctness.
132Errors are reported to
133.Dv stderr .
134This option is provided to debug configurations without making changes.
135.It Fl f Op Ar filename
136Read commands from an input file,
137.Ar filename .
138The lines of the input file are identical to the command line language.
139The
140.Ic save
141command can generate files readable by the
142.Fl f
143argument.
144.It Fl n
145Prevent attempts to print host and network names symbolically when reporting
146actions.
147This is useful, for example, when all name servers are down or are otherwise
148unreachable.
149.It Fl p
150Paranoid.
151Do not print any keying material, even if saving.
152Instead of an actual hexadecimal digit, print an
153.Sq X
154when this flag is turned on.
155.It Fl v
156Verbose.
157Print the messages being sent into the
158.Xr pf_key 4P
159socket, and print raw seconds values for lifetimes.
160.El
161.Sh COMMANDS
162.Bl -tag -width Ds
163.It Ic add
164Add an SA.
165Because it involves the transfer of keying material, this command and its
166parameters cannot be passed in as arguments to
167.Nm ,
168lest the keys be visible in
169.Xr ps 1
170output.
171It can be used either from the interactive
172.Sq tcpkey>
173prompt or in a command file specified by the
174.Fl f
175option.
176The
177.Ic add
178command accepts all extension-value pairs described below.
179.It Ic update
180Update SA lifetime extensions.
181Like
182.Ic add
183this command can only be used either from the interactive
184.Sq tcpkey>
185prompt or in a command file specified by the
186.Fl f
187option.
188The
189.Ic update
190command accepts all extension-value pairs described below with the exception
191of those used to configure algorithm or keying material, which cannot be
192changed once an SA is established.
193.It Ic delete
194Delete a specific SA.
195This command requires the
196.Sy src
197extension, and the
198.Sy dest
199extension.
200If the SA is in use, it will be marked for deletion and no longer used for new
201connection setup.
202Existing connections will however continue to use it until they are closed.
203.It Ic get
204Look up and display a security association.
205Like
206.Ic delete ,
207this command only requires
208.Sy src
209and
210.Sy dest .
211.It Ic flush
212Remove all SAs.
213.It Ic dump
214Will display all SAs.
215Because of the large amount of data generated by this command, there is no
216guarantee that all SA information will be successfully delivered, or that this
217command will even complete.
218.It Ic save
219Is the command analog of the
220.Fl s
221option.
222.It Sy help
223Prints a brief summary of commands.
224.El
225.Sh EXTENSION VALUE TYPES
226Commands like
227.Ic add ,
228.Ic delete ,
229.Ic get ,
230and
231.Ic update
232require that certain extensions and associated values be specified.
233The extensions will be listed here, followed by the commands that use them, and
234the commands that require them.
235.Pp
236.Bl -tag -width xxxxxxxxxxxxxxxxxxxx -compact
237.It Cm src Ar addr | name
238Source address of the SA.
239.It Cm src6 Ar IPv6addr
240.Pp
241.It Cm dst Ar addr | name
242Destination address of the SA.
243.It Cm dst6 Ar IPv6addr
244.Pp
245.It Cm sport Ar port
246Source port number.
247If unspecified, the SA will match any source port.
248.Pp
249.It Cm dport Ar port
250Destination port number.
251If unspecified, the SA will match any destination port.
252.Pp
253.It Cm authalg Ar algorithm
254Authentication algorithm.
255The only supported value is
256.Sq md5 .
257.It Cm authstring Ar string
258Authentication string.
259Only ASCII characters are supported and the authentication string must be no
260longer than 80 characters.
261.El
262.Pp
263The next four extensions are lifetime extensions.
264There are two varieties,
265.Dq hard
266and
267.Dq soft .
268If a hard lifetime expires, the SA will be deleted automatically by the system,
269or marked for deletion and no longer used for new connection setup if it is
270in use.
271Existing connections will continue to use the SA until they are closed.
272If a soft lifetime expires, its state is downgraded to dying from mature.
273In either case, an
274.Dv SADB_EXPIRE
275message will be queued by the system and transmitted upstream on the
276.Xr pf_key 4P
277socket the next time a downstream command is received.
278The
279.Xr ipseckey 8
280.Ic monitor
281command to key allows you to view
282.Dv SADB_EXPIRE
283messages.
284.Pp
285.Bl -tag -width xxxxxxxxxxxxxxxxxxxx -compact
286.It Cm soft_addtime
287.It Cm hard_addtime
288Specifies the number of seconds that this SA can exist after being added.
289Updating an SA does not reset the initial time that it was added.
290If the system clock has been altered since the SA was established, you may need
291to adjust the specified duration to achieve the desired outcome.
292If this extension is not present, the default value is zero, which means the SA
293will not expire based on how long it has been since it was added.
294This extension is used by the
295.Ic add
296and
297.Ic update
298commands.
299.It Cm soft_usetime
300.It Cm hard_usetime
301Specifies the number of seconds this SA can exist after first being used.
302If the system clock has been altered since the SA was first used, you may need
303to adjust the specified duration to achieve the desired outcome.
304If this extension is not present, the default value is zero, which means the SA
305will not expire based on how long it has been since it was first used.
306This extension is used by the
307.Ic add
308and
309.Ic update
310commands.
311.El
312.Sh FILES
313.Bl -tag -width Ds
314.It Pa /etc/inet/secret/tcpkeys
315Default configuration file used at boot time.
316.El
317.Sh EXAMPLES
318.Bl -tag -width 4
319.It Sy Example 1 No Empting Out All SAs
320.Bd -literal
321# tcpkey flush
322.Ed
323.It Sy Example 2 No Saving All SAs To Standard Output
324.Bd -literal
325# tcpkey save
326.Ed
327.It Sy Example 3 No Adding a pair of SAs
328.Pp
329Note that the second SA specifies 179 as the
330.Em source
331port so that it matches reply traffic.
332.Bd -literal
333# tcpkey
334tcpkey> add src 192.168.1.1 dst 192.168.1.2 dport 179 \e
335    authalg md5 authstring s3kr1t
336tcpkey> add src 192.168.1.2 dst 192.168.1.1 sport 179 \e
337    authalg md5 authstring s3kr1t
338tcpkey> exit
339.Ed
340.It Sy Example 4 No Displaying all SAs
341.Bd -literal
342# tcpkey dump
343Base message (version 2) type DUMP, SA type TCPSIG.
344Message length 112 bytes, seq=5, pid=649091.
345SRC: Source address (proto=6/tcp)
346SRC: AF_INET6: port 0, ::ffff:192.168.1.1/32 (host.example.com).
347DST: Destination address (proto=6/tcp)
348DST: AF_INET6: port 179, ::ffff:192.168.1.2/32 <unknown>.
349AST: Authentication string.
350AST: "s3kr1t"
351.Ed
352.El
353.Sh INTERFACE STABILITY
354The command line interface of
355.Nm
356is
357.Sy Uncommitted .
358The command line interface of
359.Nm
360is
361.Sy Not-An-Interface
362and may change at any time.
363.Sh SEE ALSO
364.Xr ps 1 ,
365.Xr pf_key 4P ,
366.Xr ipseckey 8
367