This guide shows how to manage your OpenVPN connections in a terminal. You will need root privileges and a .ovpn file, a config file for your OpenVPN connection. A separate username and password are optional. See optional section below.
Optional: Setup auth-user-pass
- Open or create /etc/openvpn/vpn-crednetials.txt if necessary:
sudo nano /etc/openvpn/vpn-crednetials.txt
- And add two lines (replace strings with your username and password provided by your VPN provider)
YOUR_VPN_USERNAME
YOUR_VPN_PASSWORD
- Open your .ovpn file and edit the line that begins with auth-user-pass like this:
auth-user-pass /etc/openvpn/vpn-crednetials.txt
Setup and start OpenVPN as a service (and enable it on boot)
This part shows how to setup a service for your OpenVPN configuration and how to connect to your OpenVPN service to start on boot.
- Copy your .ovpn file to /etc/openvpn/client/ like this:
sudo mv your_vpn.ovpn /etc/openvpn/client/your_vpn.conf
Note: Use .conf instead of .ovpn!
- Start the service by running:
sudo systemctl start openvpn-client@your_vpn.service
- Or run the following command to auto start the service on boot:
sudo systemctl enable openvpn-client@your_vpn.service
It is possible to manage multiple OpenVPN configurations this way.
To stop the service run:
sudo systemctl stop openvpn-client@your_vpn.service
And to disable the service on boot run:
sudo systemctl disable openvpn-client@your_vpn.service
Versionen
02/25/2024 - 04:53