How to Set Up OpenVPN for a Secure Connection?

OpenVPN is one of the most popular and reliable solutions for ensuring a secure connection when working on the internet. This protocol encrypts traffic and ensures data confidentiality, making it ideal for use on public networks. In this article, we will analyze how to set up OpenVPN for a secure connection.

Step 1: Installing OpenVPN

The first step is to install OpenVPN on your computer. To do this, go to the official OpenVPN website and download the installation file. Run the installation and follow the instructions on the screen.

Step 2: Creating an OpenVPN Server

After installation, proceed to creating an OpenVPN server. To do this, open the administrator console and enter the following commands:

sudo apt update

sudo apt install openvpn

sudo cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/openvpn/easy-rsa

After executing these commands, you will have a directory with the necessary tools for configuring the OpenVPN server.

Step 3: Configuring the Configuration File

Edit the /etc/openvpn/easy-rsa/vars file and fill it with your data:

export KEY_COUNTRY="RU"

export KEY_PROVINCE="MSK"

export KEY_CITY="Moscow"

export KEY_ORG="Organization"

export KEY_EMAIL="email@domain.com"

Save the file and close the text editor.

Step 4: Generating Certificates

Now go to the /etc/openvpn/easy-rsa directory and execute the following commands to generate certificates:

source vars

./clean-all

./build-ca

./build-key-server server

./build-dh

After executing these commands, all necessary certificates will be created in the /etc/openvpn/easy-rsa/keys directory.

Step 5: Starting the OpenVPN Server

Now that all certificates have been generated, you can start the OpenVPN server. To do this, execute the following commands:

sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/

sudo gunzip /etc/openvpn/server.conf.gz

sudo openvpn --config /etc/openvpn/server.conf

Now your OpenVPN server is up and running.

Step 6: Configuring the Client Connection

In order to connect to the OpenVPN server from a client device, you need to configure the configuration file. Create a client.ovpn file and fill it with the following content:

  • client
  • dev tun
  • proto udp
  • remote your_server_ip 1194
  • resolv-retry infinite
  • nobind
  • persist-key
  • persist-tun
  • ca ca.crt
  • cert client.crt
  • key client.key

Save the file and transfer it to the client device.

Conclusion

Now you have a secure communication channel configured using OpenVPN. By following these simple steps, you can ensure the protection of your data when working on the internet. Don’t forget about security and keep your software up to date.