1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
OpenVPN Management Interface Notes
----------------------------------
The OpenVPN Management interface allows OpenVPN to
be administratively controlled from an external program via
a TCP socket.
The interface has been specifically designed for GUI developers
and those who would like to programmatically or remotely control
an OpenVPN daemon.
The management interface is implemented using a client/server TCP
connection, where OpenVPN will listen on a provided IP address
and port for incoming management client connections.
The management protocol is currently cleartext without an explicit
security layer. For this reason, it is recommended that the
management interface either listen on localhost (127.0.0.1)
or on the local VPN address. It's possible to remotely connect
to the management interface over the VPN itself, though some
capabilities will be limited in this mode, such as the ability
to provide private key passwords.
Future versions of the management interface may allow out-of-band
connections (i.e. not over the VPN) and secured with SSL/TLS.
The management interface is enabled in the OpenVPN
configuration file using the following directives:
--management
--management-query-passwords
--management-log-cache
See the man page for documentation on these directives.
Once OpenVPN has started with the management layer enabled,
you can telnet to the management port (make sure to use
a telnet client which understands "raw" mode).
Once connected to the management port, you can use
the "help" command to list all commands.
COMMAND -- echo
---------------
The echo capability is used to allow GUI-specific
parameters to be either embedded in the OpenVPN config file
or pushed to an OpenVPN client from a server.
Command examples:
echo on -- turn on real-time notification of echo messages
echo all -- print the current echo history list
echo off -- turn off real-time notification of echo messages
echo on all -- atomically enable real-time notification,
plus show any messages in history buffer
For example, suppose you are developing a OpenVPN GUI and
you want to give the OpenVPN server the ability to ask
the GUI to forget any saved passwords.
In the OpenVPN server config file, add:
push "echo forget-passwords"
When the OpenVPN client receives its pulled list of directives
from the server, the "echo forget-passwords" directive will
be in the list, and it will cause the management interface
to save the "forget-passwords" string in its list of echo
parameters.
The management client can use "echo all" to output the full
list of echoed parameters, "echo on" to turn on real-time
notification of echoed parameters via the ">ECHO:" prefix,
or "echo off" to turn off real-time notification.
When the GUI connects to the OpenVPN management socket, it
can issue an "echo all" command, which would produce output
like this:
1101519562,forget-passwords
END
Essentially the echo command allowed us to pass parameters from
the OpenVPN server to the OpenVPN client, and then to the
management client (such as a GUI). The large integer is the
unix date/time when the echo parameter was received.
If the management client had issued the command "echo on",
it would have enabled real-time notifications of echo
parameters. In this case, our "forget-passwords" message
would be output like this:
>ECHO:1101519562,forget-passwords
Like the log command, the echo command can atomically show
history while simultaneously activating real-time updates:
echo on all
The size of the echo buffer is currently hardcoded to 100
messages.
COMMAND -- exit, quit
---------------------
Close the managment session, and resume listening on the
management port for connections from other clients. Currently,
the OpenVPN daemon can at most support a single management client
any one time.
COMMAND -- help
---------------
Print a summary of commands.
COMMAND -- hold
---------------
The hold command can be used to manipulate the hold flag,
or release OpenVPN from a hold state.
If the hold flag is set on initial startup or
restart, OpenVPN will hibernate prior to initializing
the tunnel until the management interface receives
a "hold release" command.
The --management-hold directive of OpenVPN can be used
to start OpenVPN with the hold flag set.
The hold flag setting is persistent and will not
be reset by restarts.
OpenVPN will indicate that it is in a hold state by
sending a real-time notification to the management
client:
>HOLD:Waiting for hold release
Command examples:
hold -- show current hold flag, 0=off, 1=on.
hold on -- turn on hold flag so that future restarts
will hold.
hold off -- turn off hold flag so that future restarts will
not hold.
hold release -- leave hold state and start OpenVPN, but
do not alter the current hold flag setting.
COMMAND -- kill
---------------
In server mode, kill a particlar client instance.
Command examples:
kill Test-Client -- kill the client instance having a
common name of "Test-Client".
kill 1.2.3.4:4000 -- kill the client instance having a
source address and port of 1.2.3.4:4000
Use the "status" command to see which clients are connected.
COMMAND -- log
--------------
Show the OpenVPN log file. Only the most recent n lines
of the log file are cached by the management interface, where
n is controlled by the OpenVPN --management-log-cache directive.
Command examples:
log on -- Enable real-time output of log messages.
log all -- Show currently cached log file history.
log on all -- Atomically show all currently cached log file
history then enable real-time notification of
new log file messages.
log off -- Turn off real-time notification of log messages.
log 20 -- Show the most recent 20 lines of log file history.
Real-time notification format:
Real-time log messages begin with the ">LOG:" prefix followed
by the following comma-separated fields:
(a) unix integer date/time,
(b) zero or more message flags in a single string:
I -- informational
F -- fatal error
N -- non-fatal error
W -- warning
D -- debug, and
(c) message text.
COMMAND -- mute
---------------
Change the OpenVPN --mute parameter. The mute parameter is
used to silence repeating messages of the same message
category.
Command examples:
mute 40 -- change the mute parameter to 40
mute -- show the current mute setting
COMMAND -- net
--------------
(Windows Only) Produce output equivalent to the OpenVPN
--show-net directive. The output includes OpenVPN's view
of the system network adapter list and routing table based
on information returned by the Windows IP helper API.
COMMAND -- password and username
--------------------------------
The password command is used to pass passwords to OpenVPN.
If OpenVPN is run with the --management-query-passwords
directive, it will query the management interface for RSA
private key passwords and the --auth-user-pass
username/password.
When OpenVPN needs a password from the management interface,
it will produce a real-time ">PASSWORD:" message.
Example 1:
>PASSWORD:Need 'Private Key' password
OpenVPN is indicating that it needs a password of type
"Private Key".
The management client should respond to this query as follows:
password "Private Key" foo
Example 2:
>PASSWORD:Need 'Auth' username/password
OpenVPN needs a --auth-user-pass password. The management
client should respond:
username "Auth" foo
password "Auth" bar
The username/password itself can be in quotes, and special
characters such as double quote or backslash must be escaped,
for example,
password "Private Key" "foo\"bar"
The escaping rules are the same as for the config file.
See the "Command Parsing" section below for more info.
The PASSWORD real-time message type can also be used to
indicate password or other types of authentication failure:
Example 3: The private key password is incorrect and OpenVPN
is exiting:
>PASSWORD:Verification Failed: 'Private Key'
Example 4: The --auth-user-pass username/password failed,
and OpenVPN is exiting:
>PASSWORD:Verification Failed: 'Auth'
COMMAND -- forget-passwords
---------------------------
The forget-passwords command will cause the daemon to forget passwords
entered during the session.
Command example:
forget-passwords -- forget passwords entered so far.
COMMAND -- signal
-----------------
The signal command will send a signal to the OpenVPN daemon.
The signal can be one of SIGHUP, SIGTERM, SIGUSR1, or SIGUSR2.
Command example:
signal SIGUSR1 -- send a SIGUSR1 signal to daemon
COMMAND -- state
----------------
Show the current OpenVPN state, show state history, or
enable real-time notification of state changes.
These are the OpenVPN states:
CONNECTING -- OpenVPN's initial state.
WAIT -- (Client only) Waiting for initial response
from server.
AUTH -- (Client only) Authenticating with server.
GET_CONFIG -- (Client only) Downloading configuration options
from server.
ASSIGN_IP -- Assigning IP address to virtual network
interface.
ADD_ROUTES -- Adding routes to system.
CONNECTED -- Initialization Sequence Completed.
RECONNECTING -- A restart has occurred.
EXITING -- A graceful exit is in progress.
Command examples:
state -- Print current OpenVPN state.
state on -- Enable real-time notification of state changes.
state off -- Disable real-time notification of state changes.
state all -- Print current state history.
state 3 -- Print the 3 most recent state transitions.
state on all -- Atomically show state history while at the
same time enable real-time state notification
of future state transitions.
The output format consists of 4 comma-separated parameters:
(a) the integer unix date/time,
(b) the state name,
(c) optional descriptive string (used mostly on RECONNECTING
and EXITING to show the reason for the disconnect),
(d) optional TUN/TAP local IP address (shown for ASSIGN_IP
and CONNECTED), and
(e) optional address of remote server (OpenVPN 2.1 or higher).
Real-time state notifications will have a ">STATE:" prefix
prepended to them.
COMMAND -- status
-----------------
Show current daemon status information, in the same format as
that produced by the OpenVPN --status directive.
Command examples:
status -- Show status information using the default status
format version.
status 2 -- Show status information using status format version 2.
COMMAND -- username
-------------------
See the "password" section above.
COMMAND -- verb
---------------
Change the OpenVPN --verb parameter. The verb parameter
controls the output verbosity, and may range from 0 (no output)
to 15 (maximum output). See the OpenVPN man page for additional
info on verbosity levels.
Command examples:
verb 4 -- change the verb parameter to 4
mute -- show the current verb setting
COMMAND -- version
------------------
Show the current OpenVPN and Management Interface versions.
COMMAND -- auth-retry
---------------------
Set the --auth-retry setting to control how OpenVPN responds to
username/password authentication errors. See the manual page
for more info.
Command examples:
auth-retry interact -- Don't exit when bad username/passwords are entered.
Query for new input and retry.
COMMAND -- needok (OpenVPN 2.1 or higher)
------------------------------------------
Confirm a ">NEED-OK" real-time notification, normally used by
OpenVPN to block while waiting for a specific user action.
Example:
OpenVPN needs the user to insert a cryptographic token,
so it sends a real-time notification:
>NEED-OK:Need 'token-insertion-request' confirmation MSG:Please insert your cryptographic token
The management client, if it is a GUI, can flash a dialog
box containing the text after the "MSG:" marker to the user.
When the user acknowledges the dialog box,
the management client can issue this command:
needok token-insertion-request ok
or
needok token-insertion-request cancel
COMMAND -- needstr (OpenVPN 2.1 or higher)
-------------------------------------------
Confirm a ">NEED-STR" real-time notification, normally used by
OpenVPN to block while waiting for a specific user input.
Example:
OpenVPN needs the user to specify some input, so it sends a
real-time notification:
>NEED-STR:Need 'name' input MSG:Please specify your name
The management client, if it is a GUI, can flash a dialog
box containing the text after the "MSG:" marker to the user.
When the user acknowledges the dialog box,
the management client can issue this command:
needstr name "John"
COMMAND -- pkcs11-id-count (OpenVPN 2.1 or higher)
---------------------------------------------------
Retrieve available number of certificates.
Example:
pkcs11-id-count
>PKCS11ID-COUNT:5
COMMAND -- pkcs11-id-get (OpenVPN 2.1 or higher)
-------------------------------------------------
Retrieve certificate by index, the ID string should be provided
as PKCS#11 identity, the blob is BASE64 encoded certificate.
Example:
pkcs11-id-get 1
PKCS11ID-ENTRY:'1', ID:'<snip>', BLOB:'<snip>'
OUTPUT FORMAT
-------------
(1) Command success/failure indicated by "SUCCESS: [text]" or
"ERROR: [text]".
(2) For commands which print multiple lines of output,
the last line will be "END".
(3) Real-time messages will be in the form ">[source]:[text]",
where source is "ECHO", "FATAL", "HOLD", "INFO", "LOG",
"NEED-OK", "PASSWORD", or "STATE".
REAL-TIME MESSAGE FORMAT
------------------------
The OpenVPN management interface produces two kinds of
output: (a) output from a command, or (b) asynchronous,
real-time output which can be generated at any time.
Real-time messages start with a '>' character in the first
column and are immediately followed by a type keyword
indicating the type of real-time message. The following
types are currently defined:
ECHO -- Echo messages as controlled by the "echo" command.
FATAL -- A fatal error which is output to the log file just
prior to OpenVPN exiting.
HOLD -- Used to indicate that OpenVPN is in a holding state
and will not start until it receives a
"hold release" command.
INFO -- Informational messages such as the welcome message.
LOG -- Log message output as controlled by the "log" command.
NEED-OK -- OpenVPN needs the end user to do something, such as
insert a cryptographic token. The "needok" command can
be used to tell OpenVPN to continue.
NEED-STR -- OpenVPN needs information from end, such as
a certificate to use. The "needstr" command can
be used to tell OpenVPN to continue.
PASSWORD -- Used to tell the management client that OpenVPN
needs a password, also to indicate password
verification failure.
STATE -- Shows the current OpenVPN state, as controlled
by the "state" command.
Command Parsing
---------------
The management interface uses the same command line lexical analyzer
as is used by the OpenVPN config file parser.
Whitespace is a parameter separator.
Double quotation or single quotation characters ("", '') can be used
to enclose parameters containing whitespace.
Backslash-based shell escaping is performed, using the following
mappings, when not in single quotations:
\\ Maps to a single backslash character (\).
\" Pass a literal doublequote character ("), don't
interpret it as enclosing a parameter.
\[SPACE] Pass a literal space or tab character, don't
interpret it as a parameter delimiter.
|