Install OpenVPN on AWS with Tunnelblick as a MacOS client

This is easy.

  1. Launch Free tier AWS EC2 instance
  2. Log in to the instance via SSH
  3. Make `sudo su -` to run commands as root
  4. Install system updates `apt update && apt upgrade -y`
  5. Install OpenVPN via this cool script `wget https://git.io/vpn -O i.sh && bash i.sh` (you can check contents before your run this as a root)
  6. When you answer all the questions from the setup wizard you can upload configuration via transfer.sh `curl –upload-file /root/client.ovpn https://transfer.sh/client.ovpn && echo`
  7. Open URL that transfer.sh gave you and download file
  8. Double click the file to install it to your Tunnelblick

Remote port forwarding on AWS EC2 does not open ports

Long story short, but by default SSH daemon does not open ports to the internets when you make remote port forwarding, e.g. allows to connect to ports from localhost only.
That’s smart, of course.

To allow connecting from the internets to your new ports you need to add changes to sshd config /etc/ssh/sshd_config:

Add there following line:

GatewayPorts yes

Now when you do

ssh -v -R 8080:localhost:4000 [email protected] -i ~/.ssh/key.pem

You will be able to make a request from outside 🙂