When trying to connect to a VPN via command. And you receive config files like .ovpn client .crt and .key or .p12.
- First gather config files in a same directory. For this tuto, we assume that every config file is in the directory
~/Config/VPN/myVPN. - Install
openvpnpackage from official repositories.
on Ubuntu
sudo apt-get install openvpnon Fedora
sudo dnf install openvpnon MacOs
brew install openvpnAfter instlling, make sure that the openvpn command is available in the PATH environment.
- Connection To connect to the VPN, go to the path where config files are stored and lauch the command.
cd ~/Config/VPN/myVPN
sudo openvpn --config downloaded-client-config.ovpn --pkcs12 vpn-client.domain.tld.p12or in a signle command
sudo openvpn --config ~/Config/VPN/myVPN/downloaded-client-config.ovpn --pkcs12 ~/Config/VPN/myVPN/vpn-client.domain.tld.p12If you see something like this
Thu Oct 22 12:10:46 2020 TUN/TAP device tun0 opened
Thu Oct 22 12:10:46 2020 TUN/TAP TX queue length set to 100
Thu Oct 22 12:10:46 2020 /sbin/ip link set dev tun0 up mtu 1500
Thu Oct 22 12:10:46 2020 /sbin/ip addr add dev tun0 10.***.***.***/27 broadcast 10.***.***.***
Thu Oct 22 12:10:46 2020 /sbin/ip route add ***.87.***.***/** via 192.***.***.***
Thu Oct 22 12:10:47 2020 /sbin/ip route add 0.0.0.0/1 via 10.***.***.***
Thu Oct 22 12:10:47 2020 /sbin/ip route add 128.0.0.0/1 via 10.***.***.***
Thu Oct 22 12:10:47 2020 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Thu Oct 22 12:10:47 2020 Initialization Sequence Completed
~/Config/VPN/myVPN is the path do the directory where config files are stored. You need to change it accordingly to your situation.
You can even create an alias for that
alias connectMyVPN="sudo openvpn --config ~/Config/VPN/myVPN/downloaded-client-config.ovpn --pkcs12 ~/Config/VPN/myVPN/vpn-client.domain.tld.p12"You can use alternatives for authentication.
sudo openvpn --config downloaded-client-config.ovpn --pkcs12 vpn-client.domain.tld.p12sudo openvpn --config downloaded-client-config.ovpn --cert vpn-client.domain.tld.cert --key vpn-client.domain.tld.keysudo openvpn --config downloaded-client-config.ovpn --auth-user-pass