OpenVPN Server Configuration: Management Interface.
This is the twelfth in a series of posts, featuring Protips, tips, tricks, hacks, and secrets provided by Our Team 🙊 — We want to share our top tips for the growing and thriving Linux community out there. Because sometimes you need a little help...
This series of posts explores useful OpenVPN server configuration options, including secure cryptographic algorithms, client-to-client communication, server monitoring, and remote administration.
Important: Ensure that all required options are added to and saved in your OpenVPN server configuration file, typically /etc/openvpn/server.conf. Configuration paths may vary depending on your OpenVPN installation.1. Enable the OpenVPN Management Interface
The OpenVPN Management Interface allows administrators to interact with and control an OpenVPN server in real time. It provides access to server status information, client connection details, log messages, and administrative commands.
To enable the management interface, add the following directive to your server configuration:
# Enable the management interface for administrative purposes (optional)
management 127.0.0.1 7505 /etc/openvpn/mgmt-passConfiguration breakdown:
127.0.0.1— Binds the management interface to the local loopback address, preventing direct access from external network interfaces.7505— Specifies the TCP port used by the management interface./etc/openvpn/mgmt-pass— Specifies the path to the file containing the management interface password.
Binding the interface to 127.0.0.1 is a security measure that restricts direct network access. Administrators can still access it remotely through an SSH tunnel.
Create the Management Password File
Create the password file:
$ sudo nano /etc/openvpn/mgmt-passEnter your chosen password in plaintext and save the file.
Restrict access to the file so that unauthorized users cannot read its contents:
$ sudo chmod 600 /etc/openvpn/mgmt-passSecurity note: The password file contains sensitive information.
Ensure that the OpenVPN service account can read it. Depending on how your service runs, you may need to adjust the file's ownership or permissions.
Also, verify the password-file format required by your OpenVPN version. The management interface's authentication mechanism must be configured correctly for the password file to work as intended.
Restart the OpenVPN Service
After updating the configuration, restart the OpenVPN service to apply the changes:
$ sudo systemctl restart openvpn@server.serviceCheck the service status to confirm that it started successfully:
$ sudo systemctl status openvpn@server.serviceIf your installation uses a different service name, replace openvpn@server.service with the appropriate systemd unit.
2. Telnet: Connecting to the Management Interface
We will use Telnet as a simple command-line client to communicate with the OpenVPN Management Interface.
Telnet provides an interactive, text-based connection to a TCP service. Although convenient for testing and local administration, Telnet is insecure when used over an untrusted network because it transmits data in plaintext.
In this configuration, we will use Telnet locally through an SSH tunnel rather than expose the management interface to the network.
Check Whether Telnet Is Installed
Run the following command:
$ telnetIf Telnet is installed, you should see a prompt similar to:
telnet>You can exit the prompt by entering:
$ quitAlternatively, press Ctrl+C.
If the command is not found, Telnet is probably not installed.
Install Telnet
On Ubuntu or Debian, install the Telnet client with:
$ sudo apt update
$ sudo apt install telnetNote: Telnet is used here only as a client for the local management interface.
Do not expose the OpenVPN management port directly to the internet.
3. Configure SSH Port Forwarding
To access the OpenVPN Management Interface securely from another machine, establish an SSH tunnel to the VPN server.
On your local computer, run:
$ ssh -L 7505:127.0.0.1:7505 user@your_server_ipReplace:
userwith your SSH username.your_server_ipwith the IP address or hostname of your OpenVPN server.
Authenticate using your configured SSH authentication method.
Keep this SSH session open while using the management interface.
How SSH Port Forwarding Works
The following option establishes local TCP port forwarding:
-L 7505:127.0.0.1:7505It means:
- Local port
7505: Opens a listening port on your local computer. - Remote destination
127.0.0.1: Refers to the loopback interface on the SSH server. - Remote port
7505: Identifies the OpenVPN Management Interface.
The connection follows this path:
Your Computer
|
| Telnet → 127.0.0.1:7505
|
v
SSH Tunnel (Encrypted)
|
v
OpenVPN Server
|
| 127.0.0.1:7505
|
v
OpenVPN Management InterfaceThis approach keeps the management interface bound to the server's loopback address while allowing authorized administrators to access it remotely through SSH.
4. Access the OpenVPN Management Interface
Once the SSH tunnel is established, open a second terminal on your local computer.
Connect to the forwarded port:
$ telnet 127.0.0.1 7505If the connection succeeds, you should see output similar to:
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
ENTER PASSWORD:Enter the management password configured for your OpenVPN server.
After successful authentication, the interface may display a message similar to:
SUCCESS: password is correct
>INFO:OpenVPN Management Interface Version 3 -- type 'help' for more infoThe exact output depends on your OpenVPN version and configuration.
You can now enter management commands to monitor the server and manage client connections.
5. Basic Management Interface Commands
The OpenVPN Management Interface supports several commands for monitoring and administration.
| Command | Description |
|---|---|
help | Displays available commands and usage information. |
status | Displays server status and information about connected clients. |
load-stats | Retrieves supported server statistics, where available. |
log on | Enables the display of new log messages. |
log off | Disables the display of log messages. |
log all | Requests the available log history, where supported. |
kill <client> | Terminates a client connection using the supported client identifier. |
quit | Closes the management connection. |
Note: Available commands and their exact syntax depend on your OpenVPN version. Enter help to see the commands supported by your running server.
Example: Display Server Status
To view the current status of your OpenVPN server, enter:
$ statusThe output can include connected clients, assigned VPN addresses, connection duration, and traffic statistics.
Example: Display Available Commands
To explore the management interface, enter:
$ helpThis displays the commands supported by your OpenVPN server, together with usage information where available.
Example: Disconnect a Client
To terminate a specific client session, use the kill command with the appropriate client identifier:
$ kill client_nameReplace client_name with the identifier of the client you want to disconnect. Confirm the exact syntax using the management interface's help command before executing it.
Exit the Management Interface
When you have finished administering the server, enter:
$ quitThis closes the management connection. You can also terminate the SSH session when you no longer need the tunnel.
6. Security Recommendations
Before deploying the management interface in production, consider the following precautions:
- Restrict network exposure: Bind the management interface to
127.0.0.1rather than a publicly accessible address. - Use SSH tunneling: Access the interface remotely through an authenticated SSH connection.
- Protect credentials: Restrict access to the management password file and avoid storing its contents in scripts or logs.
- Apply least privilege: Limit SSH access to authorized administrators.
- Monitor server logs: Check OpenVPN and system logs for service failures, authentication problems, and unexpected connection activity.
- Validate configuration changes: Check the service status and logs after restarting OpenVPN.
- Verify command compatibility: Use the management interface's
helpcommand because available commands can vary between OpenVPN versions.
The OpenVPN Management Interface provides administrators with a practical way to monitor server activity, inspect connected clients, review logs, and perform administrative operations.
By combining localhost binding, password protection, and SSH port forwarding, you can access these capabilities remotely without exposing the management interface directly to the network.
We hope this guide proves useful in managing and securing your OpenVPN deployment.