How to set up a Linux VPN server (script)
Articles,  Blog

How to set up a Linux VPN server (script)


In this video you will learn the simplest
and yet very reliable way to configure a personal VPN server. But why even bother. You can get a free VPN or sign up for a paid VPN service where everything is managed for you. Well, you have more control over your data
with a personal VPN server because you manage everything yourself. So, if you want to maintain total control
over your data or you are just curios how to set up a Linux VPN server, keep watching
this video. To get your own personal VPN, you need two
computers. Your local computer, most likely it is your
home computer or a laptop. It is a client computer and you use it to
connect to a VPN. And a private server, this where you install
VPN and use it as a VPN provider. This can be your own physical server or a
virtual server. If you do not have a private server, you can
get a virtual private server at UpCloud.com. Just use the promo code alu25 during the registration and you will get $25 to your account, which you can use to test VPN installation you will
see in this video. I showed how to deploy an UpCloud server in
one of my previous videos and I will use my UpCloud virtual server in this video. There are several programs you can use to
configure personal VPN. I will use OpenVPN. It is open-source, it’s available in all
Linux distro and I believe it is one of the most popular VPN programs. On the Server computer. You need to install OpenVPN and curl program: curl is needed to download the installation
script from this repository. This script makes the installation very easy
and error save. You can, of course, install everything manually,
and there are good instructions on how to do that on Debian Wiki or Arch Linux Wiki. But I believe most of my viewer prefer the
simplest ways. This script is a result of the work of 36
contributors, you can see what it does, and I personally trust it. So, you need to download the script: make it executable And run is as a superuser By the way all the commands you see in this video are provided in the description Then you need to follow the assistant and answer a few questions. I keep everything by default, so I just press
Enter for every question, except for the password protection step. I prefer to encrypt my configuration with
a password. So, I change the default option here and register
my password. When everything is done. You should see a file that ends with .ovpn. This is a configuration file we will use on
the client computer. So, on your client computer. Also, install OpenVPN and OpenVPN for your
network manager if you want to connect to your VPN with the graphical interface: I install networkmanager-openvpn for Plasma 5 on Arch Linux. Search for these two packages in your distro. If you use GNOME, you need to install networkmanager-openvpn-gnome Next, download the VPN configuration file
from your server. This is my server username and ip address. then path to the file and my local Downloads
folder. You can also use FileZilla if you prefer graphical
programs. I explained how to use FileZilla and scp command
in one of my previous videos. First I will show you the command line way
to connect to a VPN. This way is more reliable and you can make
sure that your VPN works before you configure your graphical network manager. So, copy this configuration file to the client
folder of your openVPN. And test the connection. Enter the password if you set one. If you do not see any error, everything works
fine. To test it, open your internet browser and
visit any website. You can also check your public IP address
and it should be your server address. This is my UpCloud server address. So, openVPN works and you can use it this
way. But it is much nice to be able to connect
to the VPN with just with one click from your system tray. So, let’s add this configuration to the
network manager to make it easier to connect. Open the network manager. Click on add new connection and import the
configuration file you have downloaded from the server. This is Plasma 5 network manager. It is almost the same in GNOME and other de
network managers. Just find an option to import the connection. After that, you should see a new connection
in your connection list. Try to enable it. If you see your network manager icon changes,
this means VPN works. From my experience, importing the connection
works flawlessly in the GNOME network manager. But other network managers may not recognize
all settings during the importing. You will see that your system tries to connect,
but it fails after some time. So, you can correct the errors manually. Open the configuration file and copy paste
the corresponding settings from the OpenVPN configuration file as you see on the screen
right now. These are all the key and certificates. My network manager automatically recognized
them and imported them to corresponding files. It only failed to import the tls certificate. So, I copied it manually, and saved as a tls
certificate file in my .local certificates folder and specified it in the settings. So, after I corrected all the errors, I was
able to connect to my VPN in Plasma 5 desktop. If you still cannot connect to your VPN, check the errors
in your logs with this command This is how I was able to troubleshoot my
Plasma 5 VPN connection. I recommend you to get an UpCloud server with
a promo code alu25 to get $25 to your account and test how to install and configure a VPN
connection on a private server. Thank you for watching

23 Comments

  • Average Linux User

    This tutorial including all the commands is also available as a blog-post https://averagelinuxuser.com/linux-vpn-server/

  • John Smith

    Personal vpn is unrecomended for avarage linux user. you can screw up with the setup, and leak your dns or make other mistake, second thing is that using public vpn allows you to be one of the thousands, "your" IP will be all over the place, googling "am I pregnant", buying drugs, watching gay porn, etc. It will be more difficult to track you specifically. Ofcourse vpn company always keeping logs, that's why you should also not use a vpn from your own contry, or like 5eye contries or allies of your contry. Personal vpn is only useful in places where all public ones are banned or blocked, like in China?

  • I Am Legion

    Great video !!!!.. I use Linode, Digital Ocean , and other public cloud. I will try UPcloud with your promo .. thanks .. I owe you a Starbucks!!!

  • Turtle Wax

    Hopefully a vid, with your way of explaining, can help the rookies (like me) install iTunes.
    Yeah Yeah…. I hear the boos and hisses lol! Sometimes a backup is needed for Crapple products lol

  • Datapioneer

    I have installed piVPN which is an OpenVPN server in RaspbianOS on the Raspberry Pi Model 3B+. Works great and using my DDNS FQDN I can access my piVPN server remotely on my iPad, iPhone, and Arch Linux laptop.

  • Jamie

    One big problem with VPN on Linux is the DNS leaks that happen. I use Mint and VPN does nothing to make browsing more hidden. I even downloaded the Mint Debian edition as I beleived it to be a problem with Ubuntu, and still DNS leak test exposed my data. The fixes that are available do not work for me (and many others that I have read).

    Is there any version of Lunix which does not leak the DNS when connected to VPN? I'm considering going back to Windows

  • Rakesh Misra

    could you please share the procedure where VPN server is created on the virtual machine ( as guest) and i create the VPN tunnel from the Host machine or other Virtual machine (guest) ….. if you have already shared some view , then please share the link of same

Leave a Reply

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