Home / Featured / A very detailed guide on how to setup VPN on Kali Linux and Ubuntu

A very detailed guide on how to setup VPN on Kali Linux and Ubuntu

Every day millions of people uses different VPN service providers to protect their online privacy. But it not all VPN providers are as anonymous or as secured or dedicated to protecting your Online privacy as they claim to be. A very detailed guide on how to setup VPN on Kali Linux and Ubuntu - blackMORE OpsSome VPN service providers even log your activity and if you are living in a country where certain sites are not allowed or you might get prosecuted for doing something as simple as scanning a network (yes, it’s in-fact an offense in many First World countries). I wrote this article on fixing VPN grayed out problem in Kali Linux. Many readers asked me to write a complete guide on how to set up VPN and which ones are secured.

Fact is, I simply cannot test all VPN providers. I cannot vouch for other users experiences and I usually only write stuffs I am sure about. Of many VPN providers, PrivateInternetAccess is claimed to be the best and fastest and according to their ToS and Privacy Policy, they seems to be well praised and recommended by several reviews such as done by TorrentFreak and LifeHacker. I strongly suggest readers to do some research before committing to any providers.

Following eight questions were taken from TF website and I feel that you should be asking yourself the same questions before going for any VPN providers: (I’ve added some comments below, your opinion might be different).

  1. Do you keep ANY logs which would allow you to match an IP-address and a time stamp to a user of your service? If so, exactly what information do you hold and for how long?
    • No logs.
  2. Under what jurisdictions does your company operate and under what exact circumstances will you share the information you hold with a 3rd party?
    • Out of US, GB or any NATO affiliated countries if possible. But then you compromise on speed. Alternatively suspend user account instead of handing over logs or data.
  3. What tools are used to monitor and mitigate abuse of your service?
    • Other than abuse blocking and service uptime, no monitor at all.
  4. In the event you receive a DMCA takedown notice or European equivalent, how are these handled?
    • Suspend user account instead of handing over logs or data.
  5. What steps are taken when a valid court order requires your company to identify an active user of your service?
    • Suspend user account instead of handing over logs or data.
  6. Is BitTorrent and other file-sharing traffic allowed on all servers? If not, why?
    • I never cared for BT, but I guess no discrimination on any type of traffic.
  7. Which payment systems do you use and how are these linked to individual user accounts?
    • Anything and everything. Best would be BitCoin. Setup own BTminer and pay with that. In that way, little/no online trace whatever.
  8. What is the most secure VPN connection and encryption algorithm you would recommend to your users?
    • AES-128, RSA2048 or higher supported. Don’t use SHA1. 

As I mostly use Kali Linux, my primary concentration would be on that. However, Kali Linux and Ubuntu uses same Network Manager, so this guide applies to the any Debian variant such as Kali Linux, and Ubuntu variants such as Linux Mint etc.  In short, if you follow this guide, you will be able to setup VPN on Kali Linux, Ubuntu, Debian Linux Mint etc.

Setup VPN on Kali Linux

I use Kali Linux despite many of it’s flaw and shortcomings and I have became used to it. If you’re seriously about Online privacy, stick with the distro you know and understand best. Kali is just another Linux distro and it is as secured as you make it. There are many ways you can do it. VPN to Tor to VPN via anon proxy.

Why use VPN – benefits?

Here’s my top 11 reasons why you would want to use VPN services.

  1. VPN provides Privacy and cloaks your IP address.
  2. Use any network (public or private or free WiFi) with encryption
  3. Login to your home or Work network from anywhere with confidence.
  4. Bypass censorship and content monitoring.
  5. Browse and bypass Firewall and censorship policy at work or Anywhere!
  6. Access region restricted services from anywhere (i.e. Youtube videos, NetFlix or BBC Player etc.)
  7. Transfer or receive files with privacy.
  8. Hide your voice/VOIP calls.
  9. Use Search Engines while hiding some of your identity.
  10. Hide yourself
  11. Cause you like to be anonymous.

As you can see from the list above, VPN not necessarily hides everything. Search engines can probably still recognizes you based on your cookies, previous browsing behavior, account sign-in (duh!), browser plug-ins (i.e. Alexa, Google Toolbar etc.).

Step 1: Enabling VPN on Kali Linux

By default the VPN section is grayed out on Kali Linux. You can follow my guide on fixing VPN grayed out issue (with screengrabs) or just copy paste the commands from below:

There’s two variants on the commands I’ve used, the first one enables all sorts of VPN and PPTP mumbo-junbo’s so that you don’t have to work your way through it later.

root@kali:~# aptitude -r install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome

Enable VPN on Kali Linux - blackMORE Ops - 3

The second one is more specific to VPN and just enabling VPN

root@kali:~# apt-get install network-manager-openvpn

On some cases, you might have to restart network-manager and networking,

root@kali:~# service networking restart
[....] Running /etc/init.d/networking restart is deprecated because it may not r[warnble some interfaces ... (warning).
[ ok ] Reconfiguring network interfaces...done.
root@kali:~# 
root@kali:~# service network-manager restart 
[ ok ] Stopping network connection manager: NetworkManager.
[ ok ] Starting network connection manager: NetworkManager.
root@kali:~#

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 1

Once done, it will fix your VPN grayed out issues. For other Linux distro, this isn’t so much of a problem as those packages are usually pre-installed. (which I find a waste as your distro becomes bulkier).

Step 2: Download and extract openvpn certs from PIA

Download and extract the openvpn.zip file containing ca.crt in the correct directory:

root@kali:~# wget https://www.privateinternetaccess.com/openvpn/openvpn.zip
--2015-02-27 13:14:14--  https://www.privateinternetaccess.com/openvpn/openvpn.zip
Resolving www.privateinternetaccess.com (www.privateinternetaccess.com)... 23.215.245.45
Connecting to www.privateinternetaccess.com (www.privateinternetaccess.com)|23.215.245.45|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8242 (8.0K) [application/zip]
Saving to: `openvpn.zip'

100%[======================================>] 8,242       --.-K/s   in 0s      

2015-02-27 13:14:15 (149 MB/s) - `openvpn.zip' saved [8242/8242]

root@kali:~# 
root@kali:~# unzip -q openvpn.zip -d /etc/openvpn
root@kali:~# 

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 2

Step 3: Configure Network Manager to use PIA VPN

Go to Network Manager > Edit Connections

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 3

Change to VPN Tab. VPN> Add

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 4

Click [ADD +] click the drop down menu, and set the type as OpenVPN.
Click [Create]

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 5

Go to “VPN” and fill up the following details”.

  • Connection name: PrivateInternetAccess VPN
  • Gateway:  us-east.privateinternetaccess.com [**choose Gateway's from the list below]
  • Username: PIA Username
  • Password: PIA Password
  • CA Certificate: Browse to /etc/openvpn and select ca.crt

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 6

  • Click [Advanced]: Check the box next to “Use LZO data compression
  • Click [OK], [Save] and then [Close].

Setup VPN on Kali Linux and Ubuntu - blackMORE Ops - 7

As for Gateways, choose on the following depending on your location:

PIA Regional Gateways

  • United States (US VPN)
    us-midwest.privateinternetaccess.com
    us-east.privateinternetaccess.com
    us-west.privateinternetaccess.com
    us-texas.privateinternetaccess.com
    us-california.privateinternetaccess.com
    us-florida.privateinternetaccess.com
  • Canada (CA VPN)
    ca.privateinternetaccess.com
    ca-toronto.privateinternetaccess.com
  • United Kingdom (UK VPN)
    uk-london.privateinternetaccess.com
    uk-southampton.privateinternetaccess.com
  • Switzerland (Swiss VPN)
    swiss.privateinternetaccess.com
  • Netherlands (NL VPN)
    nl.privateinternetaccess.com
  • Sweden (SE VPN)
    sweden.privateinternetaccess.com
  • France (FR VPN)
    france.privateinternetaccess.com
  • Germany (DE VPN)
    germany.privateinternetaccess.com
  • Romania (RO VPN)
    ro.privateinternetaccess.com
  • Hong Kong (HK VPN)
    hk.privateinternetaccess.com
  • Israel (Israel VPN)
    israel.privateinternetaccess.com
  • Australia (Australia VPN)
    aus.privateinternetaccess.com
  • Japan (Japan VPN)
    japan.privateinternetaccess.com

Check Also

Correct way of installing VirtualBox Guest Additions in Kali Linux 2016.2/2017 (Kali Rolling)

How to install VirtualBox Guest Additions in Kali Linux (Kali Rolling / Kali Linux 2016.2 / Kali 2017)

Since Kali Linux 2016 came out (also known as Kali Rolling), it seems that Official …

Run Kali Linux in Microsoft Azure on SSD for free - blackMORE Ops - 1

Run Kali Linux in Microsoft Azure on SSD for free

Big news for Kali Linux users, now you can run Kali Linux in Microsoft Azure …

64 comments

  1. I am from Pakistan :) I done all steps but when I connect to VPN it always shows message failed to connect to VPN and I try different Gateways like Canada, UK and US but failed to connect :(

    • Did you try to connect from Ubuntu? Unless your ISP is blocking VPN actively, there’s little reason why this should not work in Kali/Ubuntu/Debian/Linux Mint. You could also setup an Ubuntu VM within Kali and then VPN from there.

      • I am trying from Kali Linux. May be ISP is blocking but it is easier on windows to use Cyber Ghost type software for VPN.
        Ubuntu VM why?

  2. waiting for solution ;)

  3. i have installed tor is that enough or i should install VPN too ?
    can i use both of them ?

  4. Do I need a paid subscription to OpenVPN for this to work?

  5. How do I know my PIA name and PIA password? (PIA – Private internet access)

    I followed the directions but get this message. I was unsure of what to use for a PIA name, I used my Linux User Name and just made up a password. I am guessing this is not correct. I found nothing in the OpenVPN files to tell me a name or password.

    VPN connection failed.

    The VPN connection “PrivateInternetAccess VPN” failed because of invalid VPN secrets.

  6. I figured it out at the openVPN website. You have to buy a license for $9.60. That doesn’t sound bad, but you have to buy a minimum of 10. That is $96.00 when you only need one license. How much privacy do you need and what is it worth to you.

  7. Sorry, the is $96.00 a year

  8. In this article you describe the setup of VPN on Linux. While surfing on internet i found another article on the topic of How to setup VPN on MAC at VpnRanks. I want to know your point of view about this article. Thanks in advance.

  9. I’ve followed your guide, yet am unable to connect to the PIA VPN. I click on the Network Manager select the VPN and nothing happens. In System Settings under Network, the VPN is set to “off” and when but won’t stay switched to “on”. Is there a way to force the connection to stay on or use the VPN? It works on windows but doesn’t work on Kali, on either my HD install or in a VM on windows. 40 a year isn’t a bad deal but when it only works on one OS install and nothing else is a bit frustrating. Any ideas?

  10. Has anyone been able to use port 443 (host) for outbound connections? Everytime I force the host port within the kali network manager (Advanced tab: custom gateway port) my pia fails to connect. Any suggestions? thanks.

  11. What is the gateway of openvpn for India

  12. One important thing you didn’t cover in this post is does the VPN provider offer a client that locks internet access so that if the connection is lost with the VPN server, you’re not exposed.

  13. thank you for your tutorials – I’ve used them extensively and have found them to be very complete and a great help! I used this and got my PIA set up in minutes. Thanks again!

  14. No candidate version found for network-manager-openvpn-gnome
    No candidate version found for network-manager-pptp
    No candidate version found for network-manager-pptp-gnome
    No candidate version found for network-manager-strongswan
    No candidate version found for network-manager-vpnc
    No candidate version found for network-manager-vpnc-gnome
    No candidate version found for network-manager-openvpn-gnome
    No candidate version found for network-manager-pptp
    No candidate version found for network-manager-pptp-gnome
    No candidate version found for network-manager-strongswan
    No candidate version found for network-manager-vpnc
    No candidate version found for network-manager-vpnc-gnome
    No packages will be installed, upgraded, or removed.
    0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0 B of archives. After unpacking 0 B will be used.

    All i get is this message when I try to install

    • is your kali repository ok? check /etc/apt/source.list and if the source list does not contain the kali repository then add the repositories first. u can jst google kali repository and u’ll get the help from kali official website. there are also post for adding kali repository on both 1.x kali as well as kali 2.0 in this site too..

  15. crap….spoke to soon. Isn’t my ip address supposed to be obsecured now? Cause it’s not. FML

  16. IDK what i did wrong but now my network interface is no more available :3

    http://prntscr.com/7wlbv9

    Can someone help me :3

    Everything was perfect i did managed to configure pia vpn but when i was trying to connect to the vpn nothing was happening so i tried

    https://forums.kali.org/showthread.php?18597-OpenVPN-connection-won-t-start-through-Network-Manager

    elfer’s method at that time i was able to see the network interface but after i reboot it;s been gone :3

    • BlackMore, I can’t get these intructions to work with Kali2.0 – would you mind looking into this.

      I get the following error when following the PIA VPN guide (https://www.privateinternetaccess.com/pages/client-support/ubuntu-openvpn):

      Package network-manager-openvpn is required for installation. Aborting..

      And I get this error when following your guide:

      apt-get install network-manager-openvpn

      Reading package lists… Done
      Building dependency tree
      Reading state information… Done
      Package network-manager-openvpn is not available, but is referred to by another package.
      This may mean that the package is missing, has been obsoleted, or
      is only available from another source

      E: Package ‘network-manager-openvpn’ has no installation candidate

      Thanks for the help

  17. I am from Pakistan I install openvpn in kali linux 2.0 and it is not connecting

  18. Maybe iVPN could also be great for Kali Linux. https://www.ivpn.net/why-ivpn

  19. strongswan package seem to be disappeared any new commands??????????

  20. how do i configure vpn on kali linux 2.0

  21. in Kali 2.0 i can’t get a VPN tab in network settings. so no the same as earlier kali versions.

    • You can get a VPN tab by pressing the little + sign in the bottom left corner in the network settings then click “OpenVPN” I have gotten it setup but I can’t get it to connect is all.

  22. the link (https://www.privateinternetaccess.com/openvpn/openvpn.zip) is censored in my contry…how can I do?

  23. Thank you blackmoreops. You have made my Kali boot into the command line instead of the gui. I would enjoy some help

  24. hey guys!
    i run kali linux on virtual box on windows 7 and i use cyberghost 5 as a vpn on windows, can this make me anonymous while i use tools on kali?

  25. Getting
    Gnutls:Error in the pull function.
    Unable to establish SSL connection.
    What shud I do knw???

  26. When i enter this command:
    aptitude -r install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome

    This is what i get:
    No candidate version found for network-manager-openvpn-gnome
    No candidate version found for network-manager-pptp
    No candidate version found for network-manager-pptp-gnome
    Couldn’t find any package whose name or description matched “network-manager-strongswan”
    No candidate version found for network-manager-vpnc
    No candidate version found for network-manager-vpnc-gnome
    No candidate version found for network-manager-openvpn-gnome
    No candidate version found for network-manager-pptp
    No candidate version found for network-manager-pptp-gnome
    Couldn’t find any package whose name or description matched “network-manager-strongswan”
    No candidate version found for network-manager-vpnc
    No candidate version found for network-manager-vpnc-gnome
    No packages will be installed, upgraded, or removed.
    0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    Need to get 0 B of archives. After unpacking 0 B will be used.

  27. hi i don’t know how setup the password and user name ?? help please :)

  28. Hey, maybe thats a stupid question, but i cant find how to connect in auto way to my vpn?
    I used Kali 2.0, i wrote few vpn configuration in my gnome network manager but i dont have a cross or case to check to select one for autostart.
    Its a little bit annoying, for exemple, i dont see if one VPN server fall down, ive nothing to say me “HEY im down, your not secure anymore”.
    Just have to watch on the right up corner to check if im still safe. Nice, when you’re working to check all the time.

    If you have any advice, thanks again for your work.
    DpL

  29. Appreciate this article and aiming for a similar setup. How would you suggest ensuring that the VPN is used by default with Ubuntu/Kali VMs, and that network access is denied without a PIA path up and running via VPN? tia

  30. I downloaded openvpn files from the above link but when i ran them from the terminal by using command “openvpn –config …” it is asking for username and password.

  31. Good article. Installing network manager, using Kali 3.20.2

    apt-get install network-manager-openvpn-gnome

    works.

  32. when i enter this command :
    aptitude -r install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome
    error is coming :
    bash: aptitude: command not found
    what is the reason behind this error ?please help!!

    • It sounds like you don’t have aptitude installed…try:

      sudo apt-get install aptitude

      This should fix the error for most but if your OS is not up to date try running:

      sudo apt-get update
      sudo apt-get upgrade

      And then running the “sudo apt-get install aptitude” again. After aptitude is installed you should have no problem running the command in your initial comment.

  33. root@kali:/home/jeff# aptitude -r install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome
    bash: aptitude: command not found

    unable to download

  34. I wonder why nobody want to talk about “what is the username and password for this openvpn” here.. even the article above or the comments also.. nobody answer the question about what is the username and password.. So what is thePIA username and PIA password?Any web site to register account??

  35. Thanks blackmoreops.

    BTW if someone is only looking for accessing region restricted services and not doing some heavy things, you can use vpnbook instead of PIA. vpnbook is free and serves the purpose.

  36. Great article. I’m dealing with some of these issues as well..

  37. Great tutorial indeed. Still, if you want a vpn service that is plug and play, get Astrill.

  38. Idd great tutorial.

    I gonna give it a try very soon.

    On the usb 3.0 stick with Kali 2.0 I have running Tor also an recently I have installed the Opera browser, it has a VPN and it’s running very fast.

  39. tor + vpn is good for more anonymity

  40. fuck… Just download vpnbook and use it… username, password given on download page.

    #SM

Leave a Reply

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