]> git.ipfire.org Git - thirdparty/openvpn.git/blob - doc/management-notes.txt
Add unit test for encrypting/decrypting data channel
[thirdparty/openvpn.git] / doc / management-notes.txt
1 OpenVPN Management Interface Notes
2 ----------------------------------
3
4 The OpenVPN Management interface allows OpenVPN to
5 be administratively controlled from an external program via
6 a TCP or unix domain socket.
7
8 The interface has been specifically designed for developers
9 who would like to programmatically or remotely control
10 an OpenVPN daemon, and can be used when OpenVPN is running
11 as a client or server.
12
13 The management interface is implemented using a client/server TCP
14 connection or unix domain socket where OpenVPN will listen on a
15 provided IP address and port for incoming management interface client
16 connections.
17
18 The management protocol is currently cleartext without an explicit
19 security layer. For this reason, it is recommended that the
20 management interface either listen on a unix domain socket,
21 localhost (127.0.0.1), or on the local VPN address. It's possible
22 to remotely connect to the management interface over the VPN itself,
23 though some capabilities will be limited in this mode, such as the
24 ability to provide private key passwords.
25
26 The management interface is enabled in the OpenVPN
27 configuration file using the following directive:
28
29 --management
30
31 See the man page for documentation on this and related
32 directives.
33
34 Once OpenVPN has started with the management layer enabled,
35 you can telnet to the management port (make sure to use
36 a telnet client which understands "raw" mode).
37
38 Once connected to the management port, you can use
39 the "help" command to list all commands.
40
41 COMMAND -- bytecount
42 --------------------
43
44 The bytecount command is used to request real-time notification
45 of OpenVPN bandwidth usage.
46
47 Command syntax:
48
49 bytecount n (where n > 0) -- set up automatic notification of
50 bandwidth usage once every n seconds
51 bytecount 0 -- turn off bytecount notifications
52
53 If OpenVPN is running as a client, the bytecount notification
54 will look like this:
55
56 >BYTECOUNT:{BYTES_IN},{BYTES_OUT}
57
58 BYTES_IN is the number of bytes that have been received from
59 the server and BYTES_OUT is the number of bytes that have been
60 sent to the server.
61
62 If OpenVPN is running as a server, the bytecount notification
63 will look like this:
64
65 >BYTECOUNT_CLI:{CID},{BYTES_IN},{BYTES_OUT}
66
67 CID is the Client ID, BYTES_IN is the number of bytes that have
68 been received from the client and BYTES_OUT is the number of
69 bytes that have been sent to the client.
70
71 Note that when the bytecount command is used on the server, every
72 connected client will report its bandwidth numbers once every n
73 seconds.
74
75 When the client disconnects, the final bandwidth numbers will be
76 placed in the 'bytes_received' and 'bytes_sent' environmental variables
77 as included in the >CLIENT:DISCONNECT notification.
78
79 COMMAND -- echo
80 ---------------
81
82 The echo capability is used to allow GUI-specific
83 parameters to be either embedded in the OpenVPN config file
84 or pushed to an OpenVPN client from a server.
85
86 Command examples:
87
88 echo on -- turn on real-time notification of echo messages
89 echo all -- print the current echo history list
90 echo off -- turn off real-time notification of echo messages
91 echo on all -- atomically enable real-time notification,
92 plus show any messages in history buffer
93
94 For example, suppose you are developing a OpenVPN GUI and
95 you want to give the OpenVPN server the ability to ask
96 the GUI to forget any saved passwords.
97
98 In the OpenVPN server config file, add:
99
100 push "echo forget-passwords"
101
102 When the OpenVPN client receives its pulled list of directives
103 from the server, the "echo forget-passwords" directive will
104 be in the list, and it will cause the management interface
105 to save the "forget-passwords" string in its list of echo
106 parameters.
107
108 The management interface client can use "echo all" to output the full
109 list of echoed parameters, "echo on" to turn on real-time
110 notification of echoed parameters via the ">ECHO:" prefix,
111 or "echo off" to turn off real-time notification.
112
113 When the GUI connects to the OpenVPN management socket, it
114 can issue an "echo all" command, which would produce output
115 like this:
116
117 1101519562,forget-passwords
118 END
119
120 Essentially the echo command allowed us to pass parameters from
121 the OpenVPN server to the OpenVPN client, and then to the
122 management interface client (such as a GUI). The large integer is the
123 unix date/time when the echo parameter was received.
124
125 If the management interface client had issued the command "echo on",
126 it would have enabled real-time notifications of echo
127 parameters. In this case, our "forget-passwords" message
128 would be output like this:
129
130 >ECHO:1101519562,forget-passwords
131
132 Like the log command, the echo command can atomically show
133 history while simultaneously activating real-time updates:
134
135 echo on all
136
137 The size of the echo buffer is currently hardcoded to 100
138 messages.
139
140
141 Generally speaking, the OpenVPN Core does not understand echo
142 messages at all (so a cooperating GUI and Server can use this
143 mechanism for arbitrary information transport).
144
145 This said, a few echo commands have been agreed upon between the
146 community maintained OpenVPN Windows GUI and Tunnelblick for MacOS,
147 and documentation of these can be found in doc/gui-notes.txt.
148
149
150 COMMAND -- exit, quit
151 ---------------------
152
153 Close the management session, and resume listening on the
154 management port for connections from other clients. Currently,
155 the OpenVPN daemon can at most support a single management interface
156 client any one time.
157
158 COMMAND -- help
159 ---------------
160
161 Print a summary of commands.
162
163 COMMAND -- hold
164 ---------------
165
166 The hold command can be used to manipulate the hold flag,
167 or release OpenVPN from a hold state.
168
169 If the hold flag is set on initial startup or
170 restart, OpenVPN will hibernate prior to initializing
171 the tunnel until the management interface receives
172 a "hold release" command.
173
174 The --management-hold directive of OpenVPN can be used
175 to start OpenVPN with the hold flag set.
176
177 The hold flag setting is persistent and will not
178 be reset by restarts.
179
180 OpenVPN will indicate that it is in a hold state by
181 sending a real-time notification to the management interface
182 client, the parameter indicates how long OpenVPN would
183 wait without UI (as influenced by connect-retry exponential
184 backoff). The UI needs to wait for releasing the hold if it
185 wants similar behavior:
186
187 >HOLD:Waiting for hold release:10
188
189 Command examples:
190
191 hold -- show current hold flag, 0=off, 1=on.
192 hold on -- turn on hold flag so that future restarts
193 will hold.
194 hold off -- turn off hold flag so that future restarts will
195 not hold.
196 hold release -- leave hold state and start OpenVPN, but
197 do not alter the current hold flag setting.
198
199 COMMAND -- kill
200 ---------------
201
202 In server mode, kill a particular client instance.
203
204 Command examples:
205
206 kill Test-Client -- kill the client instance having a
207 common name of "Test-Client".
208 kill 1.2.3.4:4000 -- kill the client instance having a
209 source address and port of 1.2.3.4:4000
210
211 Use the "status" command to see which clients are connected.
212
213 COMMAND -- log
214 --------------
215
216 Show the OpenVPN log file. Only the most recent n lines
217 of the log file are cached by the management interface, where
218 n is controlled by the OpenVPN --management-log-cache directive.
219
220 Command examples:
221
222 log on -- Enable real-time output of log messages.
223 log all -- Show currently cached log file history.
224 log on all -- Atomically show all currently cached log file
225 history then enable real-time notification of
226 new log file messages.
227 log off -- Turn off real-time notification of log messages.
228 log 20 -- Show the most recent 20 lines of log file history.
229
230 Real-time notification format:
231
232 Real-time log messages begin with the ">LOG:" prefix followed
233 by the following comma-separated fields:
234
235 (a) unix integer date/time,
236 (b) zero or more message flags in a single string:
237 I -- informational
238 F -- fatal error
239 N -- non-fatal error
240 W -- warning
241 D -- debug, and
242 (c) message text.
243
244 COMMAND -- mute
245 ---------------
246
247 Change the OpenVPN --mute parameter. The mute parameter is
248 used to silence repeating messages of the same message
249 category.
250
251 Command examples:
252
253 mute 40 -- change the mute parameter to 40
254 mute -- show the current mute setting
255
256 COMMAND -- net
257 --------------
258
259 (Windows Only) Produce output equivalent to the OpenVPN
260 --show-net directive. The output includes OpenVPN's view
261 of the system network adapter list and routing table based
262 on information returned by the Windows IP helper API.
263
264 COMMAND -- pid
265 --------------
266
267 Shows the process ID of the current OpenVPN process.
268
269 COMMAND -- password and username
270 --------------------------------
271
272 The password command is used to pass passwords to OpenVPN.
273
274 If OpenVPN is run with the --management-query-passwords
275 directive, it will query the management interface for RSA
276 private key passwords and the --auth-user-pass
277 username/password.
278
279 When OpenVPN needs a password from the management interface,
280 it will produce a real-time ">PASSWORD:" message.
281
282 Example 1:
283
284 >PASSWORD:Need 'Private Key' password
285
286 OpenVPN is indicating that it needs a password of type
287 "Private Key".
288
289 The management interface client should respond as follows:
290
291 password "Private Key" foo
292
293 Example 2:
294
295 >PASSWORD:Need 'Auth' username/password
296
297 OpenVPN needs a --auth-user-pass username and password. The
298 management interface client should respond:
299
300 username "Auth" foo
301 password "Auth" bar
302
303 The username/password itself can be in quotes, and special
304 characters such as double quote or backslash must be escaped,
305 for example,
306
307 password "Private Key" "foo\"bar"
308
309 The escaping rules are the same as for the config file.
310 See the "Command Parsing" section below for more info.
311
312 The PASSWORD real-time message type can also be used to
313 indicate password or other types of authentication failure:
314
315 Example 3: The private key password is incorrect and OpenVPN
316 is exiting:
317
318 >PASSWORD:Verification Failed: 'Private Key'
319
320 Example 4: The --auth-user-pass username/password failed,
321 and OpenVPN will exit with a fatal error if '--auth-retry none'
322 (which is the default) is in effect:
323
324 >PASSWORD:Verification Failed: 'Auth'
325
326 Example 5: The --auth-user-pass username/password failed,
327 and the server provided a custom client-reason-text string
328 using the client-deny server-side management interface command.
329
330 >PASSWORD:Verification Failed: 'custom server-generated string'
331
332 Example 6: If server pushes --auth-token to the client, the OpenVPN
333 will produce a real-time PASSWORD message:
334
335 >PASSWORD:Auth-Token:foobar
336
337 Example 7: Static challenge/response:
338
339 >PASSWORD:Need 'Auth' username/password SC:1,Please enter token PIN
340
341 OpenVPN needs an --auth-user-pass username and password and the
342 response to a challenge. The user's response to "Please enter
343 token PIN" should be obtained and included in the management
344 interface client's response along with the username and password
345 formatted as described in the Challenge/Response Protocol section
346 below.
347
348 Example 8: Dynamic challenge/response:
349
350 >PASSWORD:Verification Failed: ['CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN']
351
352 The previous --auth-user-pass username/password failed or is not
353 fully complete, and the server provided a custom
354 client-reason-text string indicating that a dynamic
355 challenge/response should occur the next time that a "Need 'Auth'
356 username/password" message is seen.
357
358 When the next "Need 'Auth' username/password" without a static
359 challenge is seen, the user's response to "Please enter token PIN"
360 should be obtained and included in the management interface client's
361 response along with the username and password formatted as described
362 in the Challenge/Response Protocol section below
363
364 See the "Challenge/Response Protocol" section below for more details
365 about examples 7 and 8, including how the management interface client
366 should respond.
367
368 COMMAND -- forget-passwords
369 ---------------------------
370
371 The forget-passwords command will cause the daemon to forget passwords
372 entered during the session.
373
374 Command example:
375
376 forget-passwords -- forget passwords entered so far.
377
378 COMMAND -- signal
379 -----------------
380
381 The signal command will send a signal to the OpenVPN daemon.
382 The signal can be one of SIGHUP, SIGTERM, SIGUSR1, or SIGUSR2.
383
384 Command example:
385
386 signal SIGUSR1 -- send a SIGUSR1 signal to daemon
387
388 COMMAND -- state
389 ----------------
390
391 Show the current OpenVPN state, show state history, or
392 enable real-time notification of state changes.
393
394 These are the OpenVPN states:
395
396 CONNECTING -- OpenVPN's initial state.
397 WAIT -- (Client only) Waiting for initial response
398 from server.
399 AUTH -- (Client only) Authenticating with server.
400 GET_CONFIG -- (Client only) Downloading configuration options
401 from server.
402 ASSIGN_IP -- Assigning IP address to virtual network
403 interface.
404 ADD_ROUTES -- Adding routes to system.
405 CONNECTED -- Initialization Sequence Completed.
406 RECONNECTING -- A restart has occurred.
407 EXITING -- A graceful exit is in progress.
408 RESOLVE -- (Client only) DNS lookup
409 TCP_CONNECT -- (Client only) Connecting to TCP server
410 AUTH_PENDING -- (Client only) Authentication pending
411
412 Command examples:
413
414 state -- Print current OpenVPN state.
415 state on -- Enable real-time notification of state changes.
416 state off -- Disable real-time notification of state changes.
417 state all -- Print current state history.
418 state 3 -- Print the 3 most recent state transitions.
419 state on all -- Atomically show state history while at the
420 same time enable real-time state notification
421 of future state transitions.
422
423 The output format consists of up to 9 comma-separated parameters:
424 (a) the integer unix date/time,
425 (b) the state name,
426 (c) optional descriptive string (used mostly on RECONNECTING
427 and EXITING to show the reason for the disconnect),
428 (d) optional TUN/TAP local IPv4 address
429 (e) optional address of remote server,
430 (f) optional port of remote server,
431 (g) optional local address,
432 (h) optional local port, and
433 (i) optional TUN/TAP local IPv6 address.
434
435 Fields (e)-(h) are shown for CONNECTED state,
436 (d) and (i) are shown for ASSIGN_IP and CONNECTED states.
437
438 (e) is available starting from OpenVPN 2.1
439 (f)-(i) are available starting from OpenVPN 2.4
440
441 For AUTH_PENDING, if (c) is present, it would read
442 as "timeout number" where number is the number of seconds
443 before authentication will timeout. It is printed as an
444 unsigned integer (%u).
445
446 Real-time state notifications will have a ">STATE:" prefix
447 prepended to them.
448
449 COMMAND -- status
450 -----------------
451
452 Show current daemon status information, in the same format as
453 that produced by the OpenVPN --status directive.
454
455 Command examples:
456
457 status -- Show status information using the default status
458 format version.
459
460 status 3 -- Show status information using the format of
461 --status-version 3.
462
463 COMMAND -- username
464 -------------------
465
466 See the "password" section above.
467
468 COMMAND -- verb
469 ---------------
470
471 Change the OpenVPN --verb parameter. The verb parameter
472 controls the output verbosity, and may range from 0 (no output)
473 to 15 (maximum output). See the OpenVPN man page for additional
474 info on verbosity levels.
475
476 Command examples:
477
478 verb 4 -- change the verb parameter to 4
479 verb -- show the current verb setting
480
481 COMMAND -- version
482 ------------------
483
484 Set the version (integer) of Management Interface supported by the
485 client or show the current OpenVPN and Management Interface versions.
486
487 Command examples:
488 version 2 -- Change management version of client to 2 (default = 1)
489 version -- Show the version of OpenVPN and its Management Interface
490
491 COMMAND -- auth-retry
492 ---------------------
493
494 Set the --auth-retry setting to control how OpenVPN responds to
495 username/password authentication errors. See the manual page
496 for more info.
497
498 Command examples:
499
500 auth-retry interact -- Don't exit when bad username/passwords are entered.
501 Query for new input and retry.
502
503 COMMAND -- needok (OpenVPN 2.1 or higher)
504 ------------------------------------------
505
506 Confirm a ">NEED-OK" real-time notification, normally used by
507 OpenVPN to block while waiting for a specific user action.
508
509 Example:
510
511 OpenVPN needs the user to insert a cryptographic token,
512 so it sends a real-time notification:
513
514 >NEED-OK:Need 'token-insertion-request' confirmation MSG:Please insert your cryptographic token
515
516 The management interface client, if it is a GUI, can flash a dialog
517 box containing the text after the "MSG:" marker to the user.
518 When the user acknowledges the dialog box,
519 the management interface client should issue either:
520
521 needok token-insertion-request ok
522 or
523 needok token-insertion-request cancel
524
525 COMMAND -- needstr (OpenVPN 2.1 or higher)
526 -------------------------------------------
527
528 Confirm a ">NEED-STR" real-time notification, normally used by
529 OpenVPN to block while waiting for a specific user input.
530
531 Example:
532
533 OpenVPN needs the user to specify some input, so it sends a
534 real-time notification:
535
536 >NEED-STR:Need 'name' input MSG:Please specify your name
537
538 The management interface client, if it is a GUI, can flash a dialog
539 box containing the text after the "MSG:" marker to the user.
540 When the user acknowledges the dialog box,
541 the management interface client should issue this command:
542
543 needstr name "John"
544
545 COMMAND -- pkcs11-id-count (OpenVPN 2.1 or higher)
546 ---------------------------------------------------
547
548 Retrieve available number of certificates.
549
550 Example:
551
552 pkcs11-id-count
553 >PKCS11ID-COUNT:5
554
555 COMMAND -- pkcs11-id-get (OpenVPN 2.1 or higher)
556 -------------------------------------------------
557
558 Retrieve certificate by index, the ID string should be provided
559 as PKCS#11 identity, the blob is a base 64 encoded certificate.
560
561 Example:
562
563 pkcs11-id-get 1
564 PKCS11ID-ENTRY:'1', ID:'<snip>', BLOB:'<snip>'
565
566 COMMAND -- client-auth (OpenVPN 2.1 or higher)
567 -----------------------------------------------
568
569 Authorize a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request and specify
570 "client-connect" configuration directives in a subsequent text block.
571
572 The OpenVPN server should have been started with the
573 --management-client-auth directive so that it will ask the management
574 interface to approve client connections.
575
576
577 client-auth {CID} {KID}
578 line_1
579 line_2
580 ...
581 line_n
582 END
583
584 CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
585 notification for more info.
586
587 line_1 to line_n -- client-connect configuration text block, as would be
588 returned by a --client-connect script. The text block may be null, with
589 "END" immediately following the "client-auth" line (using a null text
590 block is equivalent to using the client-auth-nt command).
591
592 A client-connect configuration text block contains OpenVPN directives
593 that will be applied to the client instance object representing a newly
594 connected client.
595
596 COMMAND -- client-auth-nt (OpenVPN 2.1 or higher)
597 --------------------------------------------------
598
599 Authorize a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request without specifying
600 client-connect configuration text.
601
602 The OpenVPN server should have been started with the
603 --management-client-auth directive so that it will ask the management
604 interface to approve client connections.
605
606 client-auth-nt {CID} {KID}
607
608 CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
609 notification for more info.
610
611 COMMAND -- client-pending-auth (OpenVPN 2.5 or higher)
612 ----------------------------------------------------
613
614 Instruct OpenVPN server to send AUTH_PENDING and INFO_PRE message
615 to signal a pending authenticating to the client. A pending auth means
616 that connecting requires extra authentication like a one time
617 password or doing a single sign on via web.
618
619 client-pending-auth {CID} {KID} {EXTRA} {TIMEOUT}
620
621 The server will send AUTH_PENDING and INFO_PRE,{EXTRA} to the client. If the
622 client supports accepting keywords to AUTH_PENDING (announced via IV_PROTO),
623 TIMEOUT parameter will be also be announced to the client to allow it to modify
624 its own timeout. The client is expected to inform the user that authentication
625 is pending and display the extra information and also show the user the
626 remaining time to complete the auth if applicable.
627
628 Receiving an AUTH_PENDING message will make the client change its timeout to
629 the timeout proposed by the server, even if the timeout is shorter.
630 If the client does not receive a packet from the server for hand-window the
631 connection times out regardless of the timeout. This ensures that the connection
632 still times out relatively quickly in case of network problems. The client will
633 continuously send PULL_REQUEST messages to the server until the timeout is reached.
634 This message also triggers an ACK message from the server that resets the
635 hand-window based timeout.
636
637 Both client and server limit the maximum timeout to the smaller value of half the
638 --tls-reneg minimum time and --hand-window time (defaults to 60s).
639
640 For the format of {EXTRA} see below. For OpenVPN server this is a stateless
641 operation and needs to be followed by a client-deny/client-auth[-nt] command
642 (that is the result of the out-of-band authentication).
643
644 Note that the {KID} argument has been added in management version 5
645 to specify the pending client key the authentication belongs to.
646 This ensures that the pending auth message is tied strictly to the
647 authentication session.
648
649 Before issuing a client-pending-auth to a client instead of a
650 client-auth/client-deny, the server should check the IV_SSO
651 environment variable for whether the method is supported. Currently,
652 defined methods are crtext for challenge/response using text
653 (e.g., TOTP), openurl (deprecated) and webauth for opening a URL in
654 the client to continue authentication. A client supporting webauth and
655 crtext would set
656
657 setenv IV_SSO webauth,crtext
658
659 The variable name IV_SSO is historic as AUTH_PENDING was first used
660 to signal single sign on support. To keep compatibility with existing
661 implementations the name IV_SSO is kept in lieu of a better name.
662
663 The management interface of the client receives notification of
664 pending auth via
665
666 >STATE:datetime,AUTH_PENDING,[timeout number],,,,,
667
668 If {EXTRA} is present the client is informed using INFOMSG
669 notification as
670
671 >INFOMSG:{EXTRA}
672
673 where {EXTRA} is formatted as received from the server.
674 Currently defined formats for {EXTRA} are detailed below.
675
676 webauth and openurl
677 ===================
678 For a web based extra authentication (like for
679 SSO/SAML) {EXTRA} should be
680
681 OPEN_URL:url
682
683 or
684
685 WEB_AUTH:flags:url
686
687 The OPEN_URL method is deprecated as it does not allow to send flags which
688 proved to be needed to signal certain behaviour to the client.
689
690 The client should ask the user to open the URL to continue.
691
692 The space in a control message is limited, so this url should be kept
693 short to avoid issues. If a longer url is required a URL that redirects
694 to the longer URL should be sent instead. The total length is limited to 1024
695 bytes which includes the INFO_PRE:WEB_AUTH:flags.
696
697 flags is a list of flags which are separated by commas. Currently defined
698 flags are:
699
700 - proxy (see next pargraph)
701 - hidden start the webview in hidden mode (see openvpn3 webauth documentation)
702 - external Do not use an internal webview but use an external browser. Some
703 authentication providers refuse to work in an internal webview.
704
705
706 A complete documentation how URLs should be handled on the client is available
707 in the openvpn3 repository:
708
709 https://github.com/OpenVPN/openvpn3/blob/master/doc/webauth.md
710
711 webauth with proxy
712 ==================
713 This is a variant of webauth that allows opening a url via an
714 HTTP proxy. It could be used to avoid issues with OpenVPN connection's
715 persist-tun that may cause the web server to be unreachable.
716 The client should announce proxy in its IV_SSO and parse the
717 proxy flag in the WEB_AUTH message. The format of {EXTRA} in this case is
718
719 WEB_AUTH:proxy=<proxy>;<proxy_port>;<proxy_user_base64>;<proxy_password_base64>,flags:url
720
721 The proxy should be a literal IPv4 address or IPv6 address enclosed in [] to avoid
722 ambiguity in parsing. A literal IP address is preferred as DNS might not be
723 available when the client needs to open the url. The IP address will usually
724 be the address that client uses to connect to the VPN server. For dual-homed
725 VPN servers, the server should respond with the same address that the client
726 connects to.
727
728 This address is also usually excluded from being redirected over the VPN
729 by a host route. If the platform (like Android) uses another way of protecting
730 the VPN connection from routing loops, the client needs to also exclude the
731 connection to the proxy in the same manner.
732
733 Should another IP be used, then the VPN configuration should include a route
734 statement to exclude that address from being routed over the VPN.
735
736 crtext
737 =======
738 The format of {EXTRA} is similar to the already used two step authentication
739 described in Challenge/Response Protocol section of this document. Since
740 most of the fields are not necessary or can be inferred, only the <flags>
741 and <challenge_text> fields are used:
742
743 CR_TEXT:<flags>:<challenge_text>
744
745 <flags>: a series of optional, comma-separated flags:
746 E : echo the response when the user types it.
747 R : a response is required.
748
749 <challenge_text>: the challenge text to be shown to the user.
750
751 The client should return the response to the crtext challenge
752 using the cr-response command.
753
754 COMMAND -- client-deny (OpenVPN 2.1 or higher)
755 -----------------------------------------------
756
757 Deny a ">CLIENT:CONNECT" or ">CLIENT:REAUTH" request.
758
759 client-deny {CID} {KID} "reason-text" ["client-reason-text"]
760
761 CID,KID -- client ID and Key ID. See documentation for ">CLIENT:"
762 notification for more info.
763
764 reason-text: a human-readable message explaining why the authentication
765 request was denied. This message will be output to the OpenVPN log
766 file or syslog.
767
768 client-reason-text: a message that will be sent to the client as
769 part of the AUTH_FAILED message.
770
771 Note that client-deny denies a specific Key ID (pertaining to a
772 TLS renegotiation). A client-deny command issued in response to
773 an initial TLS key negotiation (notified by ">CLIENT:CONNECT") will
774 terminate the client session after returning "AUTH-FAILED" to the client.
775 On the other hand, a client-deny command issued in response to
776 a TLS renegotiation (">CLIENT:REAUTH") will invalidate the renegotiated
777 key, however the TLS session associated with the currently active
778 key will continue to live for up to --tran-window seconds before
779 expiration.
780
781 To immediately kill a client session, use "client-kill".
782
783 COMMAND -- client-kill (OpenVPN 2.1 or higher)
784 -----------------------------------------------
785
786 Immediately kill a client instance by CID.
787
788 client-kill {CID}
789
790 CID -- client ID. See documentation for ">CLIENT:" notification for more
791 info.
792
793 COMMAND -- remote-entry-count (OpenVPN 2.6+ management version > 3)
794 -------------------------------------------------------------------
795
796 Retrieve available number of remote host/port entries
797
798 Example:
799
800 Management interface client sends:
801
802 remote-entry-count
803
804 OpenVPN daemon responds with
805
806 5
807 END
808
809 COMMAND -- remote-entry-get (OpenVPN 2.6+ management version > 3)
810 ------------------------------------------------------------------
811
812 remote-entry-get <start> [<end>]
813
814 Retrieve remote entry (host, port, protocol, and status) for index
815 <start> or indices from <start> to <end>-1. Alternatively
816 <start> = "all" retrieves all remote entries. The index is 0-based.
817 If the entry is disabled due to protocol or proxy restrictions
818 (i.e., ce->flag & CE_DISABLED == 1), the status is returned as "disabled",
819 otherwise it reads "enabled" without quotes.
820
821 Example 1:
822
823 Management interface client sends:
824
825 remote-entry-get 1
826
827 OpenVPN daemon responds with
828
829 1,vpn.example.com,1194,udp,enabled
830 END
831
832 Example 2:
833
834 Management interface client sends:
835
836 remote-entry-get 1 3
837
838 OpenVPN daemon responds with
839
840 1,vpn.example.com,1194,udp,enabled
841 2,vpn.example.net,443,tcp-client,disabled
842 END
843
844 Example 3:
845 Management interface client sends:
846
847 remote-entry-get all
848
849 OpenVPN daemon with 3 connection entries responds with
850
851 0,vpn.example.com,1194,udp,enabled
852 1,vpn.example.com,443,tcp-client,enabled
853 2,vpn.example.net,443,udp,enabled
854 END
855
856 COMMAND -- remote (OpenVPN AS 2.1.5/OpenVPN 2.3 or higher)
857 --------------------------------------------
858
859 Provide remote host/port in response to a >REMOTE notification
860 (client only). Requires that the --management-query-remote
861 directive is used.
862
863 remote ACTION [HOST PORT]
864
865 The "remote" command should only be given in response to a >REMOTE
866 notification. For example, the following >REMOTE notification
867 indicates that the client config file would ordinarily connect
868 to vpn.example.com port 1194 (UDP):
869
870 >REMOTE:vpn.example.com,1194,udp
871
872 Now, suppose we want to override the host and port, connecting
873 instead to vpn.otherexample.com port 1234. After receiving
874 the above notification, use this command:
875
876 remote MOD vpn.otherexample.com 1234
877
878 To accept the same host and port as the client would ordinarily
879 have connected to, use this command:
880
881 remote ACCEPT
882
883 To skip the current connection entry and advance to the next one,
884 use this command:
885
886 remote SKIP
887
888 Starting OpenVPN version 2.6 (management version > 3), skip
889 multiple remotes using:
890
891 remote SKIP n
892
893 where n > 0 is the number of remotes to skip.
894
895 COMMAND -- proxy (OpenVPN 2.3 or higher)
896 --------------------------------------------
897
898 Provide proxy server host/port and flags in response to a >PROXY
899 notification (client only). Requires that the --management-query-proxy
900 directive is used.
901
902 proxy TYPE HOST PORT ["nct"]
903
904 The "proxy" command must only be given in response to a >PROXY
905 notification. Use the "nct" flag if you only want to allow
906 non-cleartext auth with the proxy server. The following >PROXY
907 notification indicates that the client config file would ordinarily
908 connect to the first --remote configured, vpn.example.com using TCP:
909
910 >PROXY:1,TCP,vpn.example.com
911
912 Now, suppose we want to connect to the remote host using the proxy server
913 proxy.intranet port 8080 with secure authentication only, if required.
914 After receiving the above notification, use this command:
915
916 proxy HTTP proxy.intranet 8080 nct
917
918 You can also use the SOCKS keyword to pass a SOCKS server address, like:
919
920 proxy SOCKS fe00::1 1080
921
922 To accept connecting to the host and port directly, use this command:
923
924 proxy NONE
925
926 COMMAND -- cr-response (OpenVPN 2.5 or higher)
927 -------------------------------------------------
928 Provides support for sending responses to a challenge/response
929 query via INFOMSG,CR_TEXT (client-only). The response should
930 be base64 encoded:
931
932 cr-response SGFsbG8gV2VsdCE=
933
934 This command is intended to be used after the client receives a
935 CR_TEXT challenge (see client-pending-auth section). The argument
936 to cr-response is the base64 encoded answer to the challenge and
937 depends on the challenge itself. For a TOTP challenge this would be
938 a number encoded as base64; for a challenge like "what day is it today?"
939 it would be a string encoded as base64.
940
941 COMMAND -- pk-sig (OpenVPN 2.5 or higher, management version > 1)
942 COMMAND -- rsa-sig (OpenVPN 2.3 or higher, management version <= 1)
943 -----------------------------------------------------------------
944 Provides support for external storage of the private key. Requires the
945 --management-external-key option. This option can be used instead of "key"
946 in client mode, and allows the client to run without the need to load the
947 actual private key. When the SSL protocol needs to perform a sign
948 operation, the data to be signed will be sent to the management interface
949 via a notification as follows:
950
951 >PK_SIGN:[BASE64_DATA],[ALG] (if client announces support for management version > 2)
952 >PK_SIGN:[BASE64_DATA] (if client announces support for management version > 1)
953 >RSA_SIGN:[BASE64_DATA] (only older clients will be prompted like this)
954
955 The management interface client should then create an appropriate signature of
956 the (decoded) BASE64_DATA using the private key and return the SSL signature as
957 follows:
958
959 pk-sig (or rsa-sig)
960 [BASE64_SIG_LINE]
961 .
962 .
963 .
964 END
965
966 Base 64 encoded output of RSA_private_encrypt for RSA or ECDSA_sign()
967 for EC using OpenSSL or mbedtls_pk_sign() using mbed TLS will provide a
968 correct signature.
969 The rsa-sig interface expects PKCS1 padded signatures for RSA keys
970 (RSA_PKCS1_PADDING). EC signatures are always unpadded.
971
972 This capability is intended to allow the use of arbitrary cryptographic
973 service providers with OpenVPN via the management interface.
974
975 New and updated clients are expected to use the version command to announce
976 a version > 1 and handle '>PK_SIGN' prompt and respond with 'pk-sig'.
977
978 The signature algorithm is indicated in the PK_SIGN request only if the
979 management client-version is > 2. In particular, to support TLS1.3 and
980 TLS1.2 using OpenSSL 1.1.1, unpadded signature support is required and this
981 can be indicated in the signing request only if the client version is > 2"
982
983 The currently defined padding algorithms are:
984
985 - RSA_PKCS1_PADDING - PKCS1 padding and RSA signature
986 - RSA_NO_PADDING - No padding may be added for the signature
987 - ECDSA - EC signature.
988 - RSA_PKCS1_PSS_PADDING,params - RSA signature with PSS padding
989
990 The params for PSS are specified as 'hashalg=name,saltlen=[max|digest]'.
991
992 The hashalg names are short common names such as SHA256, SHA224, etc.
993 PSS saltlen="digest" means use the same size as the hash to sign, while
994 "max" indicates maximum possible saltlen which is
995 '(nbits-1)/8 - hlen - 2'. Here 'nbits' is the number of bits in the
996 key modulus and 'hlen' the size in octets of the hash.
997 (See: RFC 8017 sec 8.1.1 and 9.1.1)
998
999 In the case of PKCS1_PADDING, when the hash algorithm is not legacy
1000 MD5-SHA1, the hash is encoded with DigestInfo header before presenting
1001 to the management interface. This is identical to CKM_RSA_PKCS in Cryptoki
1002 as well as what RSA_private_encrypt() in OpenSSL expects.
1003
1004 COMMAND -- certificate (OpenVPN 2.4 or higher)
1005 ----------------------------------------------
1006 Provides support for external storage of the certificate. Requires the
1007 --management-external-cert option. This option can be used instead of "cert"
1008 in client mode. On SSL protocol initialization a notification will be sent
1009 to the management interface with a hint as follows:
1010
1011 >NEED-CERTIFICATE:macosx-keychain:subject:o=OpenVPN-TEST
1012
1013 The management interface client should use the hint to obtain the specific
1014 SSL certificate and then return base 64 encoded certificate as follows:
1015
1016 certificate
1017 [BASE64_CERT_LINE]
1018 .
1019 .
1020 .
1021 END
1022
1023 This capability is intended to allow the use of certificates
1024 stored outside of the filesystem (e.g. in Mac OS X Keychain)
1025 with OpenVPN via the management interface.
1026
1027 OUTPUT FORMAT
1028 -------------
1029
1030 (1) Command success/failure indicated by "SUCCESS: [text]" or
1031 "ERROR: [text]".
1032
1033 (2) For commands which print multiple lines of output,
1034 the last line will be "END".
1035
1036 (3) Real-time messages will be in the form ">[source]:[text]",
1037 where source is "CLIENT", "ECHO", "FATAL", "HOLD", "INFO", "LOG",
1038 "NEED-OK", "PASSWORD", or "STATE".
1039
1040 REAL-TIME MESSAGE FORMAT
1041 ------------------------
1042
1043 The OpenVPN management interface produces two kinds of
1044 output: (a) output from a command, or (b) asynchronous,
1045 real-time output which can be generated at any time.
1046
1047 Real-time messages start with a '>' character in the first
1048 column and are immediately followed by a type keyword
1049 indicating the type of real-time message. The following
1050 types are currently defined:
1051
1052 BYTECOUNT -- Real-time bandwidth usage notification, as enabled
1053 by "bytecount" command when OpenVPN is running as
1054 a client.
1055
1056 BYTECOUNT_CLI -- Real-time bandwidth usage notification per-client,
1057 as enabled by "bytecount" command when OpenVPN is
1058 running as a server.
1059
1060 CLIENT -- Notification of client connections and disconnections
1061 on an OpenVPN server. Enabled when OpenVPN is started
1062 with the --management-client-auth option. CLIENT
1063 notifications may be multi-line. See "The CLIENT
1064 notification" section below for detailed info.
1065
1066 ECHO -- Echo messages as controlled by the "echo" command.
1067
1068 FATAL -- A fatal error which is output to the log file just
1069 prior to OpenVPN exiting.
1070
1071 HOLD -- Used to indicate that OpenVPN is in a holding state
1072 and will not start until it receives a
1073 "hold release" command.
1074
1075 INFO -- Informational messages such as the welcome message.
1076
1077 LOG -- Log message output as controlled by the "log" command.
1078
1079 NEED-OK -- OpenVPN needs the end user to do something, such as
1080 insert a cryptographic token. The "needok" command can
1081 be used to tell OpenVPN to continue.
1082
1083 NEED-STR -- OpenVPN needs information from end, such as
1084 a certificate to use. The "needstr" command can
1085 be used to tell OpenVPN to continue.
1086
1087 PASSWORD -- Used to tell the management interface client that OpenVPN
1088 needs a password, also to indicate password
1089 verification failure.
1090
1091 STATE -- Shows the current OpenVPN state, as controlled
1092 by the "state" command.
1093
1094 INFOMSG -- Authentication related info from server such as
1095 CR_TEXT or OPEN_URL. See description under client-pending-auth
1096
1097 The CLIENT notification
1098 -----------------------
1099
1100 The ">CLIENT:" notification is enabled by the --management-client-auth
1101 OpenVPN configuration directive that gives the management interface client
1102 the responsibility to authenticate OpenVPN clients after their client
1103 certificate has been verified. CLIENT notifications may be multi-line, and
1104 the sequentiality of a given CLIENT notification, its associated environmental
1105 variables, and the terminating ">CLIENT:ENV,END" line are guaranteed to be
1106 atomic.
1107
1108 CLIENT notification types:
1109
1110 (1) Notify new client connection ("CONNECT") or existing client TLS session
1111 renegotiation ("REAUTH"). Information about the client is provided
1112 by a list of environmental variables which are documented in the OpenVPN
1113 man page. The environmental variables passed are equivalent to those
1114 that would be passed to an --auth-user-pass-verify script.
1115
1116 >CLIENT:CONNECT|REAUTH,{CID},{KID}
1117 >CLIENT:ENV,name1=val1
1118 >CLIENT:ENV,name2=val2
1119 >CLIENT:ENV,...
1120 >CLIENT:ENV,END
1121
1122 (2) Notify successful client authentication and session initiation.
1123 Called after CONNECT.
1124
1125 >CLIENT:ESTABLISHED,{CID}
1126 >CLIENT:ENV,name1=val1
1127 >CLIENT:ENV,name2=val2
1128 >CLIENT:ENV,...
1129 >CLIENT:ENV,END
1130
1131 (3) Notify existing client disconnection. The environmental variables passed
1132 are equivalent to those that would be passed to a --client-disconnect
1133 script.
1134
1135 >CLIENT:DISCONNECT,{CID}
1136 >CLIENT:ENV,name1=val1
1137 >CLIENT:ENV,name2=val2
1138 >CLIENT:ENV,...
1139 >CLIENT:ENV,END
1140
1141 (4) Notify that a particular virtual address or subnet
1142 is now associated with a specific client.
1143
1144 >CLIENT:ADDRESS,{CID},{ADDR},{PRI}
1145
1146 (5) Text based challenge/Response
1147
1148 >CLIENT:CR_RESPONSE,{CID},{KID},{response_base64}
1149 >CLIENT:ENV,name1=val1
1150 >CLIENT:ENV,name2=val2
1151 >CLIENT:ENV,...
1152 >CLIENT:ENV,END
1153
1154 Use of the cr-response command on the client side will trigger this
1155 message on the server side.
1156
1157 CR_RESPONSE notification fulfills the same purpose as the
1158 CRV1 response in the traditional challenge/response. See that section
1159 below for more details. Since this uses the same cid as in the original
1160 client-pending-auth challenge, we do not include the username and opaque
1161 session data in this notification. The string {response_base64} only contains
1162 the actual response received from the client.
1163
1164 It is important to note that OpenVPN2 merely passes the authentication
1165 information and does not do any further checks. (E.g. if a CR was issued
1166 before or if multiple CR responses were sent from the client or if
1167 data has a valid base64 encoding)
1168
1169 This interface should be be sufficient for almost all challenge/response
1170 system that can be implemented with a single round and base64 encoding of the
1171 response. Mechanisms that need multiple rounds or more complex answers
1172 should implement a different response type than CR_RESPONSE.
1173
1174
1175 Variables:
1176
1177 CID -- Client ID, numerical ID for each connecting client, sequence = 0,1,2,...
1178 KID -- Key ID, numerical ID for the key associated with a given client TLS session,
1179 sequence = 0,1,2,...
1180 PRI -- Primary (1) or Secondary (0) VPN address/subnet. All clients have at least
1181 one primary IP address. Secondary address/subnets are associated with
1182 client-specific "iroute" directives.
1183 ADDR -- IPv4 address/subnet in the form 1.2.3.4 or 1.2.3.0/255.255.255.0
1184
1185 In the unlikely scenario of an extremely long-running OpenVPN server,
1186 CID and KID should be assumed to recycle to 0 after (2^32)-1, however this
1187 recycling behavior is guaranteed to be collision-free.
1188
1189 Command Parsing
1190 ---------------
1191
1192 The management interface uses the same command line lexical analyzer
1193 as is used by the OpenVPN config file parser.
1194
1195 Whitespace is a parameter separator.
1196
1197 Double quotation or single quotation characters ("", '') can be used
1198 to enclose parameters containing whitespace.
1199
1200 Backslash-based shell escaping is performed, using the following
1201 mappings, when not in single quotations:
1202
1203 \\ Maps to a single backslash character (\).
1204 \" Pass a literal doublequote character ("), don't
1205 interpret it as enclosing a parameter.
1206 \[SPACE] Pass a literal space or tab character, don't
1207 interpret it as a parameter delimiter.
1208
1209 Challenge/Response Protocol
1210 ---------------------------
1211
1212 The OpenVPN Challenge/Response Protocol allows an OpenVPN server to
1213 generate challenge questions that are shown to the user, and to see
1214 the user's responses to those challenges. Based on the responses, the
1215 server can allow or deny access.
1216
1217 The protocol can be used to implement multi-factor authentication
1218 because the user must enter an additional piece of information,
1219 in addition to a username and password, to successfully authenticate.
1220 In multi-factor authentication, this information is used to prove
1221 that the user possesses a certain key-like device such as
1222 cryptographic token or a particular mobile phone.
1223
1224 Two variations on the challenge/response protocol are supported:
1225 the "static" and "dynamic" protocols:
1226
1227 * The static protocol uses OpenVPN's "--static-challenge" option.
1228
1229 * The dynamic protocol does not involve special OpenVPN options
1230 or actions. It is an agreement between the auth-user-pass
1231 verification process on the server and the management interface
1232 client to use custom strings that begin with "['CRV1" in
1233 "Verification Failed" messages. (The "[" character and a matching
1234 "]" character at the end of the message are added by the client
1235 OpenVPN program, and are not present in the string generated by the
1236 auth-user-pass verification process or in the string sent by the
1237 server.)
1238
1239 Dynamic protocol:
1240
1241 The OpenVPN dynamic challenge/response protocol works by returning
1242 a specially formatted error message after initial successful
1243 authentication. The error message has two purposes:
1244
1245 1. It causes OpenVPN to restart the connection attempt.
1246
1247 2. It contains information about the challenge, which should be used
1248 to construct the response to the next authentication request (which
1249 will occur after the restart).
1250
1251 Notes:
1252
1253 * '--auth-retry interact' must be in effect so that the
1254 connection is restarted and credentials are requested again.
1255
1256 * '--auth-retry none' (which is the default) will cause
1257 OpenVPN to exit with a fatal error without retrying and the dynamic
1258 challenge/response will never happen because "Need 'Auth'
1259 username/password" will not be sent.
1260
1261 The error message is formatted as follows:
1262
1263 >PASSWORD:Verification Failed: 'Auth' ['CRV1:<flags>:<state_id>:<username_base64>:<challenge_text>']
1264
1265 <flags>: a series of optional, comma-separated flags:
1266 E : echo the response when the user types it.
1267 R : a response is required.
1268
1269 <state_id>: an opaque string that should be returned to the server
1270 along with the response.
1271
1272 <username_base64>: the username encoded as base 64.
1273
1274 <challenge_text>: the challenge text to be shown to the user.
1275
1276 <state_id> may not contain colon characters (":"), but <challenge_text>
1277 may.
1278
1279 Example challenge:
1280
1281 CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN
1282
1283 The next time the username and password are requested with
1284
1285 >PASSWORD:Need 'Auth' username/password
1286
1287 the management interface client should display the challenge text and,
1288 if the R flag is specified, get a response from the user. The management
1289 interface client should respond:
1290
1291 username "Auth" <username>
1292 password "Auth" CRV1::<state_id>::<response_text>
1293
1294 Where <username> is the username decoded from <username_base64>,
1295 <state_id> is taken from the challenge request, and <response_text>
1296 is what the user entered in response to the challenge, which can be an
1297 empty string. If the R flag is not present, <response_text> should
1298 be an empty string.
1299
1300 (As in all username/password responses described in the "COMMAND --
1301 password and username" section above, the username and/or password
1302 can be in quotes, and special characters such as double quotes or
1303 backslashes must be escaped. See the "Command Parsing" section above
1304 for more info.)
1305
1306 Example response (suppose the user enters "8675309" for the token PIN):
1307
1308 username "Auth" cr1
1309 password "Auth" CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::8675309
1310
1311 ("Y3Ix" is the base 64 encoding of "cr1".)
1312
1313 Static protocol:
1314
1315 The static protocol differs from the dynamic protocol in that the
1316 challenge question is sent to the management interface client in a
1317 a username/password request, and the username, password, and
1318 response are delivered back to the server in response to that
1319 request.
1320
1321 OpenVPN's --static-challenge option is used to provide the
1322 challenge text to OpenVPN and indicate whether or not the response
1323 should be echoed.
1324
1325 When credentials are needed and the --static-challenge option is
1326 used, the management interface will send:
1327
1328 >PASSWORD:Need 'Auth' username/password SC:<ECHO>,<TEXT>
1329
1330 ECHO: "1" if response should be echoed, "0" to not echo
1331 TEXT: challenge text that should be shown to the user to
1332 facilitate their response
1333
1334 For example:
1335
1336 >PASSWORD:Need 'Auth' username/password SC:1,Please enter token PIN
1337
1338 The above notification indicates that OpenVPN needs a --auth-user-pass
1339 username and password plus a response to a static challenge ("Please
1340 enter token PIN"). The "1" after the "SC:" indicates that the response
1341 should be echoed.
1342
1343 The management interface client in this case should add the static
1344 challenge text to the auth dialog followed by a field for the user to
1345 enter a response. Then the management interface client should pack the
1346 password and response together into an encoded password and send:
1347
1348 username "Auth" <username>
1349 password "Auth" "SCRV1:<password_base64>:<response_base64>"
1350
1351 Where <username> is the username entered by the user, <password_base64>
1352 is the base 64 encoding of the password entered by the user, and
1353 <response_base64> is the base 64 encoding of the response entered by
1354 the user. The <password_base64> and/or the <response_base64> can be
1355 empty strings.
1356
1357 (As in all username/password responses described in the "COMMAND --
1358 password and username" section above, the username can be in quotes,
1359 and special characters such as double quotes or backslashes must be
1360 escaped. See the "Command Parsing" section above for more info.)
1361
1362 For example, if user "foo" entered "bar" as the password and 8675309
1363 as the PIN, the following management interface commands should be
1364 issued:
1365
1366 username "Auth" foo
1367 password "Auth" "SCRV1:YmFy:ODY3NTMwOQ=="
1368
1369 ("YmFy" is the base 64 encoding of "bar" and "ODY3NTMwOQ==" is the
1370 base 64 encoding of "8675309".)