This project provides a comprehensive guide on how to set up a VPN server on a VPS using OpenVPN. Follow the instructions below to deploy and configure your VPN server.
OpenVPN is a robust and highly flexible open-source VPN (Virtual Private Network) software that enables secure point-to-point or site-to-site connections. It provides a secure and encrypted connection over the internet, ensuring privacy and data integrity. OpenVPN is widely used for remote access, secure communications, and bypassing geo-restrictions.
- Security: OpenVPN uses strong encryption protocols to protect your data from unauthorized access.
- Flexibility: It can be configured to work on various platforms and devices.
- Reliability: OpenVPN is known for its stability and performance.
- Open Source: Being open-source, it is continuously improved and audited by the community.
Before you begin, ensure you have the following:
- A VPS (Virtual Private Server) with a fresh installation of a supported Linux distribution (e.g., Ubuntu, Debian).
- An Azure account to deploy the VM.
- Putty installed on your local machine for SSH access.
- Basic knowledge of Linux command-line operations.
- Deploy the VM on Azure
- How to connect using Putty
- Basic Start Command (Must do!!!)
- Create a non-root user
- Installing the server
- Changing the directory for the ovpn file
- Disable Logs
- Restart the VPN Server
- How to download the files to your windows machine
- If you are lost follow this
- Troubleshooting
- Make sure this is in username rather than SSH public key
- After creating the VM, click on connect
- Copy the SSH command only behind
sudo apt-get update && apt-get upgrade
Example output:
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
...
sudo apt install neovim
Example output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libmsgpackc2 libtermkey1 libvterm0 neovim-runtime
...
sudo useradd -G sudo -m <username> -s /bin/bash
Example output:
sudo passwd <username>
Example output:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
sudo apt install wget
Example output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpsl5 publicsuffix wget
...
wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
Example output:
--2023-07-02 03:48:23-- https://git.io/vpn
Resolving git.io (git.io)... 140.82.113.21
Connecting to git.io (git.io)|140.82.113.21|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh [following]
--2023-07-02 03:48:23-- https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15345 (15K) [text/plain]
Saving to: ‘openvpn-install.sh’
openvpn-install.sh 100%[===================>] 15.00K --.-KB/s in 0.001s
2023-07-02 03:48:23 (11.4 MB/s) - ‘openvpn-install.sh’ saved [15345/15345]
sudo bash openvpn-install.sh
Example output:
Welcome to the OpenVPN installer!
The git repository is available at: https://github.com/angristan/openvpn-install
I need to ask you a few questions before starting the setup.
You can use the default options and just press enter if you are unsure.
...
sudo mv /root/<VPN file name example Aftershock.ovpn> .
Example output:
sudo nvim /etc/openvpn/server/server.conf
Example output:
After entering insert mode by pressing the "i" key in Nvim, you can type or modify the text as needed. To save the changes and exit the editor, you can follow these steps:
- Press the "Esc" key on your keyboard to exit insert mode and return to normal mode in Nvim.
- Once you're in normal mode, you can save the changes by typing
:w
(colon followed by the letter "w"). This command tells Nvim to write (save) the file. - After entering
:w
, press the "Enter" key to execute the command. You should see a message indicating that the file has been saved. - To exit Nvim, type
:q
(colon followed by the letter "q") and press "Enter". This command tells Nvim to quit the editor.- If you have unsaved changes and want to quit without saving, you can use
:q!
instead, which discards the changes and forces the exit.
- If you have unsaved changes and want to quit without saving, you can use
By following these steps, you should be able to save your changes and exit the Nvim editor.
sudo systemctl restart openvpn-server@server.service
Example output:
pscp username@public_ip_address:/path/to/file C:\Downloads
Example output:
pscp CLF@52.123.45.67:thinkpad.ovpn C:\chanl\Downloads
Example output:
- Solution: Ensure that the VM is running and the SSH port (usually port 22) is open in the VM's network security group settings.
- Solution: Make sure you are using a user with sudo privileges. If you are using a non-root user, prefix the commands with
sudo
.
- Solution: Check the OpenVPN server logs for any error messages. You can view the logs using the following command:
sudo journalctl -u openvpn-server@server.service
- Solution: Ensure that the
pscp
command is installed on your Windows machine. You can download it from the official PuTTY website. Also, verify that the file path and IP address are correct.
For further assistance, refer to the official OpenVPN documentation or seek help from the OpenVPN community.