This brief tutorial will show you how to set up your own personal VPN network, allowing you to:
- SSH into your work computer from home, or your home computer from work.
- Read journal articles that you have access to at work, but not from home.
- Create a secure/encrypted connection to either home or work while travelling and using non-trusted networks.
In order to do this we will be using:
- An Amazon EC2 free-tier instance [NOTE: Free only for the first year!]
- OpenVPN with high-security SSL certificates (no passwords)
- tinyproxy for HTTP/S proxying
Disclaimer: Punching holes in firewalls/paywalls may or may not be allowed in your country/workplace. Journals often specifically permit it under their Terms and Conditions, but it is up to you to make sure. Also check with your work's IT security peoples that this is OK, because they may not be happy that you can access internal resources from outside of their multi-thousand-dollar-deep-packet-inspecting firewalls.
Step 1: Create a publicly-accessible server to host your Virtual Private Network
There are many ways to get two computers which are both behind firewalls to talk to one another, however, the simplest and most stable method is to have them both connect to a 3rd party with no networking restrictions. This third computer should ideally be always-on, cheap to run, and accept all incoming traffic on our VPN port. For this we will use a free-tier EC2 server from Amazon Web Services. To set this up, go to aws.amazon.com and make yourself an account if you don't already have one:
You will be asked for some personal details, your address, and finally a credit or debit card. Although nothing in this tutorial will require money, Amazon just wants to make it easy for you to "upgrade" in the future by getting payment details now...
Once you've created an account, go to the console page and click on EC2:
Launch a new instance:
And then select the Amazon Linux AMI (Free Tier Eligible). If you're not familiar with AWS, an AMI is just a virtual operating system image, kind of like a .iso for those who have installed virtual machines in the past.
Regarding setup, just click next next next until you come to "Step 6: Configure Security Group", and add a new rule for HTTPS traffic like so:
After this click Launch. You may get a warning about the server being "open to the world". This is because your allowing SSH from any IP address -- but don't worry, AWS by default uses asymmetric Private Key for SSH (the same thing we will later used for our VPN), which is essentially unhackable unless someone gets hold of your private key. Download your private key, store it in a safe place, and click Launch.
If all goes well you will be congratulated with a green popup box telling you the instance ID of your new virtual server, starting with "i-". Click on that ID to go to its management page:
If all goes well, your server will come online and you will see it's IP address:
Next you're going to want to change the permissions of that key file you downloaded to something more secure like 500, and then ssh into your shiny new server like so:
The warnings your seeing there are totally normal and nothing to worry about. The hostname of the Amazom AMI is "ec2-user" which is easy to forget, so perhaps write it down somewhere.
To finish up installing our 3rd party server, run (but don't paste!):
sudo yum-config-manager --enable epel
sudo yum update
sudo yum install openvpn
sudo yum install tinyproxy
sudo yum install easy-rsa
Note you will have to type "y" a few times as you do the above.
We're now ready to start step 2 - configuring our VPN!
Thank you for this nice tutorial. A few points:
Thanks Giovanni - I have modified the first post because that is pretty important! :D
Many workplaces would not allow an unsupported/ third-party VPN to run .. assuming they know what they are doing in terms of security.
At least in the US most (large) universities probably provide an official VPN. Sounds like that is not the case in Europe.
If you have access to an official work VPN then that's going to be much easier than setting all this up! Having said that, running your own gives you a bit more security and flexibility than using your universities.
Someone putting in this much effort will hopefully be security conscious and will have taken necessary precautions to protect their laptop/desktop against threats (e.g. malware/infections etc). Once a VPN session is established the external machine has indirect access to the internal network.
@John: You should consider adding language/warning to this effect to the disclaimer at the top.
Security is only as strong as the weakest link in the chain.
Perhaps I haven't explained well enough how this kind of VPN differs from a university's VPN. A Uni VPN would act like an access point that lets clients pretend they are inside the university network, so all their traffic (software updates, credit card details, bittorrent, etc) goes via the University network to the internet. Depending on the university's network setup, this may or may not even give you access to the compute servers, particularly if the servers are on a different subnet to the VPN clients. Since all your network traffic goes through the university, when you browse the web you'll browse with the universities IP address only. There may or may not be encryption.
The kind of VPN we are setting up here is ideal for Bioinformaticians, because all it does is allow computers you have access for to talk to one another no matter where in the world they are. Unlike the Uni VPN, clients won't use the VPN for all communications - just data going to/from the 10.8.0.x IP addresses via this new tun0 network adapter.
Here's a quick network diagram:
So unlike a regular VPN setup, here the home laptop doesn't have unrestricted access to the internal work network at all. It only can "see" your one work computer, explicitly put on the VPN, and even then that work computer will require an SSH username/password before it will let you do anything interesting.
Thank you for clarifying the scope of the VPN you are describing. I do have one comment.
Most universities use split tunneled VPN so traffic designated for university's IP blocks goes through the VPN while rest of the internet traffic still goes through your home ISP. Local policies control what sort of access clients coming in via VPN IP space will have to rest of resources but most places probably consider your VPN connection legit once you are able to create the original authenticated VPN tunnel.
I have modified my comment above.
We have our own VPN in a european city. I think most europenan universities have it, if not all. We used for accessing WOK bibliographic database, and many other local facilities that require the recognition of a University IP
You chose the Amazon Linux AMI, and you are using a Macbook. What if I'm using the windows pc, what OS should I choose and what will the procedures be in configuring the VPN
Instead of using terminal from OS X you would download an SSH client for Windows (PuTTY, SSH Secure Shell (look for v. 3.2.9 hint: available from some academic websites)) and use that.