Submitted by knife on Sun, 02/25/2024 - 04:53
Manage OpenVPN connections within a terminal
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-credentials.txt if necessary:
sudo nano /etc/openvpn/vpn-credentials.txt
- And add two lines (replace strings with your username and password provided by your VPN provider)
YOUR_VPN_USERNAME YOUR_VPN_PASSWORD
- and save it.
- Open your .ovpn file and edit the line that begins with auth-user-pass like this:
auth-user-pass /etc/openvpn/vpn-credentials.txt
- and save it.
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.confNote: 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.serviceIt is possible to manage multiple OpenVPN configurations this way. To stop the service run:
sudo systemctl stop openvpn-client@your_vpn.serviceAnd to disable the service on boot run:
sudo systemctl disable openvpn-client@your_vpn.service
Revisions
02/25/2024 - 04:53