With ShellsTM you can run a VPN (Virtual Private Network) server using OpenVPN on Ubuntu. And this can be done right from your smart TV, Android or iPhone as well. With a VPN server you can have multiple devices connected on the same network for easy file sharing or to encrypt your connection when accessing a public hotspot like at a cafe on an unsecured network. In this article we will be configuring an OpenVPN server on Ubuntu 20.04 in five steps:
- Updating your System
- Finding your public IP
- Server Installation
- Adding Clients
- Connecting Clients
Step 1 - Updating your System
Update Ubuntu with apt command to run system update
sudo apt update && sudo apt upgrade
Step 2 - Finding your public IP
If you have purchased a public IP, you can find it on your Shells Dash board once logged into your account by selecting “Your ShellsTM” on left side panel then clicking on Edit to the right of your selected shell. You should see your public IP address displaying to the right of Host:
Step 3 – Server installation
Download and run openvpn-install.sh bash script using wget
wget https://git.io/vpn -O openvpn-ubuntu-install.sh
Next we need to make the script executable using chmod
sudo chmod -v +x openvpn-ubuntu-install.sh
You should see output as below:
Now we can run openvpn-ubuntu-install.sh script to install OpenVPN server
sudo ./openvpn-ubuntu-install.sh
Follow the steps as the script runs confirming your public IP, selecting DNS and creating a user by pressing enter to go to each next step. See below:
Now lets move the user file we created using the mv command to make it easier to locate and access. This is the client opvn file we just created.
sudo mv ~root/myshelluser1.opvn ~ubuntuuser/myshelluser1.opvn
Make sure to replace the ubuntu user and file name with your username and file name.
Restart/enable OpenVPN server on Ubuntu 20.04 LTS
Lets use systemctl to restart OpenVPN so the configuration is applied, enable it so that it will run at startup and verify that it is running with the status command.
Restart the OpenVPN server
sudo systemctl restart openvpn-server@server.service
Enable the OpenVPN server
sudo systemctl enable openvpn-server@server.service
Status of the OpenVPN server
sudo systemctl status openvpn-server@server.service
Status output:
Next we need to open UDP port 1164 using ufw so we can access the server remotely.
sudo ufw allow 1194/udp
To enable the ufw firewall on Ubuntu 20.04 see article Is there a firewall in my Shell?
Step 4 – Adding Clients
To add clients we just need to run the script again and press option 1.
sudo ./openvpn-ubuntu-install.sh
Running the script again, also, will allow you to remove users, or uninstall the OpenVPN server.
Step 5 - Connecting Clients
You can now copy the client opvn file, in my case the shellsuser1.opvn file, using SCP (Linux/MacOS), WinSCP (Windows), AndFTP (Android) or FTPManager (Apple iOS).
Once you have your opvn file transferred over to your device, you can use the OpenVPN client software to connect.
I used the Windows client and imported the ovpn file to connect to my server. Now I can ping both server and client and share the same network as my ShellsTM from a Windows, Mac, or Android/ iPhone by just importing the opvn file.
Comments
0 comments
Article is closed for comments.