installopenvpn with the /go/installopenvpn Command

/go/installopenvpn turns the server into a VPN server. When it finishes, you can connect from a laptop or phone with the OpenVPN client, and all of the client's internet traffic goes out through this server. In one run it: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Run as root
/go/installopenvpn

Answer the prompts as described in Output. When it finishes, download config.ovpn and import it into your OpenVPN client.

Options

There are no command-line options. To change the settings, edit the variables at the top of the script before you run it:

Variable Default Notes
SERVER_IP Empty (detected automatically) The public address clients connect to. Set it if the detection is wrong, for example behind NAT.
OPENVPN_PORT 1194 The port the server listens on.
OPENVPN_PROTOCOL udp udp or tcp.
CLIENT_NAME config The name of the first client and of its .ovpn file.

Fixed in the script: the VPN subnet is 10.8.0.0/24, clients get Google’s DNS servers (8.8.8.8 and 8.8.4.4), and all client traffic is sent through the VPN.

Examples

# Install the server and create the first client
/go/installopenvpn

# Check the service afterwards
systemctl status openvpn-server@server

# Connect from a Linux client with the saved file
sudo openvpn --config config.ovpn

# Create another client (no helper is included for this)
cd /etc/openvpn/easy-rsa
./easyrsa build-client-full laptop nopass

The last example only creates the certificate and key. You have to build the .ovpn file for that client yourself, using config.ovpn as a template.

Output

The command prints a heading for each step (--- Installing OpenVPN, Easy-RSA, --- Setting up Easy-RSA PKI ---, and so on).

It is not fully unattended. Easy-RSA stops and asks you to:

  1. press Enter to accept the Common Name of the certificate authority
  2. press Enter to accept the Common Name of the server request
  3. type yes to confirm signing the server certificate

If the server’s public IP can’t be detected, it also asks you to type it.

Generating the Diffie-Hellman parameters can take several minutes.

At the end it prints:

OpenVPN client configuration file '/usr/local/goadmio/home/go/vpn/config.ovpn' created successfully.
--- OpenVPN server and client setup finished ---

Outcome What you get
Success The messages above.
A step fails Error: ... and exit status 1. Nothing is rolled back.
Not run as root This script must be run as root or with sudo. Exit status 1.

Every run is logged to /var/log/go/installopenvpn.log with a timestamp and the arguments used.

See the full reference at /go/installopenvpn and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *