Skip to content

on demand vpn endpoint using ansible, amazon and sshuttle

License

Notifications You must be signed in to change notification settings

reneluria/tupeuxpasvpn

Repository files navigation

TuPeuxPasVPN

On-demand ansible provided VPN endpoint, using aws ec2 and sshuttle

Dependencies

Installation

Nothing to install if deps are already met.

Otherwise:

pipenv shell

or

python3 -m venv venv
. venv/bin/activate
python3 -m pip install -U pip wheel
python3 -m pip install -r requirements.txt

Usage

To create an ssh endpoint in London:

SSH_AUTH_SOCK= ansible-playbook create-instance.yml -e 'region=eu-west-2'

It creates a vm in the given ec2 region and adds it to inventory.

It also creates a helper script in artifacts folder.

Launch VPN like this:

./artifacts/start-vpn.sh

And in another terminal you can check where you apparently are:

$ curl ipinfo.io
{
  "ip": "3.8.174.42",
  "hostname": "ec2-3-8-174-42.eu-west-2.compute.amazonaws.com",
  "city": "London",
  "region": "London, City of",
  "country": "GB",
  "loc": "51.5115,-0.0912",
  "postal": "EC4R",
  "org": "AS16509 Amazon.com, Inc."
}

And remove this instance when you're done:

ansible-playbook delete-instance.yml -e 'region=eu-west-2'

Notes

  • This recipe generates a ssh keypair for this purpose

  • The VM is created with a security group allowing only your public ip to connect to it

  • You need to set your aws cli config or EC2_ACCESS_KEY and EC2_SECRET_KEY variables

  • Feel free to adapt the template of the vpn script to make it less verbose and daemonize for example

Author

Rene Luria

About

on demand vpn endpoint using ansible, amazon and sshuttle

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages