2 Easy Methods to Setup OpenVPN server on ubuntu in under 10 minutes

Generally setting up an OpenVPN server is a daunting task for non linux Users, which can easily take 40 minutes to an hour for a first time user.  However there are 2 extremely easy ways of setting it up in under 10 minutes.

Method 1 : By Installing OpenVPN Access Server ( AS)

This is the easiest method that can get you a fully working server up and running in under 5 minutes.  You have to just download the installation file and run it. All the basic configuration is out of the box.  All the advanced configuration ( if you need), user creation, profile download etc is done via a graphical user inteface in your webbrowser, and you never have to see the command line .



There is a limitation however to the free version, you only get 2 free concurrent users for testing. If 2 users is all you want, use OpenVPN AS as this is the easiest way to install the VPN server.

Step 1.1 : Download the package

Step 1.2 : Run the installation package

You should be able to double click on the downloaded package .  If you are running a headless server, or only have access to command line, then run the dpkg command to run the installation

dpkg -i openvpn-as-2.0.5-Ubuntu10.amd_64.deb

Substituting the openvpn-as-2.0.5-Ubuntu10.amd_64.deb for the name of the package file you have downloaded

Step 1.3 : Change Default Password

Now your OpenVPN AS has been installed for you already and a default admin user openvpn has been created. Change the password for this user by running

passwd openvpn

 

Step 1.4 : Access your OpenVPN GUI, and add a user.

Open your web browser and go to  https://openvpnasip:943/admin , replacing openvpnasip as your server ip.  Use the default user name ‘openvpn’ and the password that you had set in step 1.3
Add one more user by visiting the user section.  You can add as many users as you want, but only 2 users can be connected to the server at a time.

Step 1.5 : download the .ovpn profile

login to  https://openvpnasip:943/?src=connect
Login as the user you want to connect and download the .ovpn profile for this user.  Import this .ovpn profile in your OpenVPN client and connect with the respective username and password

Method 2 : By Using a containerization application

There is an excellent container by Kylemanna for docker that can be used to setup a full OpenVPN server.

Step 2.1 : Install docker if you don’t have it on your system

Though you can run sudo apt-get install docker-ce , it will mostly get you an old version.  To get the latest version, add the docker official repository and install from there.
Add Docker official GPG key
curl -fsSLhttps://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
set up the stable repository.
sudo add-apt-repository   "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the apt package index.
$ sudo apt-get update
Install docker

sudo apt-get install docker-ce

Test that docker has been installed by running
docker run hello-world

Step 2.2 :  Pull the image to your sytem

Copy the image to your system by running
sudo docker pull kylemanna/openvpn

Step 2.3 : Prepare your volume

You need to create a docker volume which will hold your configuration and certificates . Choose a name for the $OVPN_DATA volume.  Save the name to the variable $OVPN_DATA , so we can easily reference this variable.
OVPN_DATA="ovpn-data-example"
Create the Volume and initialize it. It will ask a passphrase, remember this since you will need it while creating your client certificate.
docker volume create --name $OVPN_DATA
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn
ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn ovpn_initpki

Step 2.4 : Generate client certificate and download config

Generate the client certificate with
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
And dump a copy of the client configuration with
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
Import CLIENTNAME.ovpn to your openvpn client and connect. Since we created the certificate with no pass option, you can connect without password.

Filenames on network share different from actual file names Qnap

Problem :
The filename you see in ftp and filemanager in Qnap is correct. But a strange name (often with ~) is shown for this file when you access your network share.  See the below screen shot

Solution :

This happens because Samba is serving shortfile name in 8.3 format to you . SAMBA is used to make a linux share look like a windows share.  However for some files ( where the filename has a special character), samba may show the filename as conventional 8 char long.

To solve this you have to enable “Only allows applications to access files using the long file format”.

 

  • Go to “Control Panel” > “Privilege” > “Shared Folders”.
  • Click on the shared folder which has this problem
  • Click on “Edit Properties”, the button that has a pencil on it
  • Enable “Only allows applications to access files using the long file format”.
  • Click “ok”

After this , the applications will have access to the full long file format

 

Openvpn process killed after “Initialization Sequence Completed “

Problem :
Your openvpn client on ubuntu doesn’t connect to your server.  After “Initialization sequence complete” the process is killed.

A Log Excerpt , after the last step the process is killed
Sun Jul 8 14:13:58 2018 GID set to nogroup
Sun Jul 8 14:13:58 2018 UID set to nobody
Sun Jul 8 14:13:58 2018 Initialization Sequence Completed

Solution :
Make sure that your openvpn client is latest 2.4.  Ubuntu official repository gives you an outdated version. once you update, the problem should disappear.

here is how to update to the latest client

https://community.openvpn.net/openvpn/wiki/OpenvpnSoftwareRepos

Find all the duplicate photos on your Qnap with findimagedupes

You may have a lot of duplicate images on your hard drives. Now Exact duplicate images are easy to find and delete with fdupes, but what about images that are different size, cropped, or different just a bit visually ?
findimagedupes is a command line tool that finds visually similar images, even if they are of different resolution and size. There is a threshold setting to define how much similar two images have to be.
Install findimagedupes with  apt-get install findimagedupes
The simplest form to run is
findimagedupes -R ~/images
this finds all the duplicate images recursively in all subdirectorie of ~/images.
A more complete form which I generally use is

findimagedupes -v=fp  -R -f=fp_data  ~/images</div>

  • -v  : verbose mode. You can see fingerprint of eachfile with fp, or md5 hash with md5.  For some reason the option -v=LIST specified in the command help doesn’t work. You only can get -v=md5 or -v=fp to work.
  • -R  : recursively search all subdirectories
  • -f   :  This is a file to we are going to write to / or read from , each images fingerprint . especially useful for large directories with lots of images.
Generally I would let it run first for sometime so that I have all the files scanned and their signatures saved in fp_data.  On next run, the program reads off the fp_data file and runs a lot more faster.
To use a photo viewer like feh, use the -p switch with full path . This is what you should do if you want to see the pairs and delete one or more of them.  Feh lets you navigate in each set , delete the images and then move on to the next set.
-p doesn’t work with simple program name, even if this exist in your system path. You have to always specify the full path of the program.
findimagedupes -v=fp  -R -f=fp_data  -p= /usr/bin/feh ~/images
You can also set the threshold. To find Exactly same visual image, set the threshold to 100 for example
findimagedupes -v=fp  -R -f=fp_data  -p= /usr/bin/feh -t=100 ~/images

 

Couchpotato and TBP ” No ThePirateBay proxies left, please add one in settings, or let us know which one to add on the forum.”

Problem : Couchpotato doesn’t snatch any file from TBP.

Error message is

ERROR[se.providers.torrent.base] No ThePirateBay proxies left, please add one in settings, or let us know which one to add on the forum.

Solution : Add to proxy and change the search url

You have 2 python files for thepiratebay in Couchpotato.

/opt/CouchPotatoServer/couchpotato/core/media/_base/providers/torrent/thepiratebay.py
/opt/CouchPotatoServer/couchpotato/core/media/movie/providers/torrent/thepiratebay.py

We need to modify the first one inside  media/_base/providers/torrent/

You need to modify at 2 places

  1. Add the url to tbp to proxy_list

This is the list of all the urls that the website can be accessed from. at my location today I can access tbp through https://thepiratebay3.org, so I have to add it to the list of Proxies

proxy_list = [
'https://pirateproxy.cat',
'https://pirateproxy.wf',
'https://pirateproxy.tf',
'https://urbanproxy.eu',
'https://piratebays.co',
'https://pirateproxy.yt',
'https://thepiratebay.uk.net',
'https://thebay.tv',
'https://thepirateproxy.co',
'https://theproxypirate.pw',
'https://arrr.xyz',
'https://tpb.dashitz.com',
'https://thepiratebay3.org'
]

Make sure that you add a comma after the last entry , and use the space bar to indent it just below the last entry since python uses indented code.

2. update the Search url :

The Default search url in this file is websiteroot/search/search_term

however, when I search , I see that that the search url should be websiteroot/index.php?q=search_term.

So in the following code change the search term from 'search': '%s/search/%%s/%%s/7/%%s' , to  'search': '%s/index.php?q=%%s/%%s/7/%%s'

class Base(TorrentMagnetProvider):
urls = {
'detail': '%s/torrent/%s',
'search': '%s/index.php?q=%%s/%%s/7/%%s'
}

That’s it , restart your couchpotato and it should start working