Skip to content

Commit 8bdd99c

Browse files
jackivanovreaperhulk
authored andcommitted
Refactor to support Ansible 2.8 (#1549)
* bump ansible to 2.8.3 * DigitalOcean: move to the latest modules * Add Hetzner Cloud * Scaleway and Lightsail fixes * lint missing roles * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <[email protected]> * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <[email protected]> * Try to run apt until succeeded * Scaleway modules upgrade * GCP: Refactoring, remove deprecated modules * Doc updates (#1552) * Update README.md Adding links and mentions of Exoscale aka CloudStack and Hetzner Cloud. * Update index.md Add the Hetzner Cloud to the docs index * Remove link to Win 10 IPsec instructions * Delete client-windows.md Unnecessary since the deprecation of IPsec for Win10. * Update deploy-from-ansible.md Added sections and required variables for CloudStack and Hetzner Cloud. * Update deploy-from-ansible.md Added sections for CloudStack and Hetzner, added req variables and examples, mentioned environment variables, and added links to the provider role section. * Update deploy-from-ansible.md Cosmetic changes to links, fix typo. * Update GCE variables * Update deploy-from-script-or-cloud-init-to-localhost.md Fix a finer point, and make variables list more readable. * update azure requirements * Python3 draft * set LANG=c to the p12 password generation task * Update README * Install cloud requirements to the existing venv * FreeBSD fix * env->.env fixes * lightsail_region_facts fix * yaml syntax fix * Update README for Python 3 (#1564) * Update README for Python 3 * Remove tabs and tweak instructions * Remove cosmetic command indentation * Update README.md * Update README for Python 3 (#1565) * DO fix for "found unpermitted parameters: id" * Verify Python version * Remove ubuntu 16.04 from readme * Revert back DigitalOcean module * Update deploy-from-script-or-cloud-init-to-localhost.md * env to .env
1 parent 61729ac commit 8bdd99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+879
-958
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ README.md
99
config.cfg
1010
configs
1111
docs
12-
env
12+
.env
1313
logo.png
1414
tests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
configs/*
44
inventory_users
55
*.kate-swp
6-
env
6+
*env
77
.DS_Store
88
venvs/*
99
!venvs/.gitinit

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
language: python
3-
python: "2.7"
3+
python: "3.7"
44
dist: xenial
55

66
services:
@@ -12,7 +12,7 @@ addons:
1212
- sourceline: 'ppa:ubuntu-lxc/stable'
1313
- sourceline: 'ppa:wireguard/wireguard'
1414
packages: &default_packages
15-
- python-pip
15+
- python3-pip
1616
- lxd
1717
- expect-dev
1818
- debootstrap
@@ -22,7 +22,7 @@ addons:
2222
- build-essential
2323
- libssl-dev
2424
- libffi-dev
25-
- python-dev
25+
- python3-dev
2626
- linux-headers-$(uname -r)
2727
- wireguard
2828
- libxml2-utils
@@ -63,7 +63,7 @@ stages:
6363
- pip install ansible-lint
6464
- shellcheck algo install.sh
6565
- ansible-playbook main.yml --syntax-check
66-
- ansible-lint -v *.yml
66+
- ansible-lint -v *.yml roles/{local,cloud-*}/*/*.yml
6767

6868
- &deploy-local
6969
stage: Deploy

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:2-alpine
1+
FROM python:3-alpine
22

33
ARG VERSION="git"
44
ARG PACKAGES="bash libffi openssh-client openssl rsync tini"
@@ -16,11 +16,11 @@ RUN mkdir -p /algo && mkdir -p /algo/configs
1616
WORKDIR /algo
1717
COPY requirements.txt .
1818
RUN apk --no-cache add ${BUILD_PACKAGES} && \
19-
python -m pip --no-cache-dir install -U pip && \
20-
python -m pip --no-cache-dir install virtualenv && \
21-
python -m virtualenv env && \
22-
source env/bin/activate && \
23-
python -m pip --no-cache-dir install -r requirements.txt && \
19+
python3 -m pip --no-cache-dir install -U pip && \
20+
python3 -m pip --no-cache-dir install virtualenv && \
21+
python3 -m virtualenv .env && \
22+
source .env/bin/activate && \
23+
python3 -m pip --no-cache-dir install -r requirements.txt && \
2424
apk del ${BUILD_PACKAGES}
2525
COPY . .
2626
RUN chmod 0755 /algo/algo-docker.sh

README.md

Lines changed: 52 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40AlgoVPN)](https://twitter.com/AlgoVPN)
55
[![TravisCI Status](https://api.travis-ci.org/trailofbits/algo.svg?branch=master)](https://travis-ci.org/trailofbits/algo)
66

7-
Algo VPN is a set of Ansible scripts that simplify the setup of a personal IPSEC and Wireguard VPN. It uses the most secure defaults available, works with common cloud providers, and does not require client software on most devices. See our [release announcement](https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/) for more information.
7+
Algo VPN is a set of Ansible scripts that simplify the setup of a personal Wireguard and IPSEC VPN. It uses the most secure defaults available, works with common cloud providers, and does not require client software on most devices. See our [release announcement](https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/) for more information.
88

99
## Features
1010

@@ -14,7 +14,7 @@ Algo VPN is a set of Ansible scripts that simplify the setup of a personal IPSEC
1414
* Blocks ads with a local DNS resolver (optional)
1515
* Sets up limited SSH users for tunneling traffic (optional)
1616
* Based on current versions of Ubuntu and strongSwan
17-
* Installs to DigitalOcean, Amazon Lightsail, Amazon EC2, Vultr, Microsoft Azure, Google Compute Engine, Scaleway, OpenStack, or [your own Ubuntu server](docs/deploy-to-ubuntu.md)
17+
* Installs to DigitalOcean, Amazon Lightsail, Amazon EC2, Vultr, Microsoft Azure, Google Compute Engine, Scaleway, OpenStack, CloudStack, Hetzner Cloud, or [your own Ubuntu server](docs/deploy-to-ubuntu.md)
1818

1919
## Anti-features
2020

@@ -27,49 +27,57 @@ Algo VPN is a set of Ansible scripts that simplify the setup of a personal IPSEC
2727

2828
## Deploy the Algo Server
2929

30-
The easiest way to get an Algo server running is to let it set up a _new_ virtual machine in the cloud for you.
31-
32-
1. **Setup an account on a cloud hosting provider.** Algo supports [DigitalOcean](https://m.do.co/c/4d7f4ff9cfe4) (most user friendly), [Amazon Lightsail](https://aws.amazon.com/lightsail/), [Amazon EC2](https://aws.amazon.com/), [Vultr](https://www.vultr.com/), [Microsoft Azure](https://azure.microsoft.com/), [Google Compute Engine](https://cloud.google.com/compute/), [Scaleway](https://www.scaleway.com/), and [DreamCompute](https://www.dreamhost.com/cloud/computing/) or other OpenStack-based cloud hosting.
33-
34-
2. **[Download Algo](https://github.com/trailofbits/algo/archive/master.zip).** Unzip it in a convenient location on your local machine.
35-
36-
3. **Install Algo's core dependencies.** Open the Terminal. The `python` interpreter you use to deploy Algo must be python2. If you don't know what this means, you're probably fine. `cd` into the `algo-master` directory where you unzipped Algo, then run:
37-
38-
- macOS:
39-
```bash
40-
$ python -m ensurepip --user
41-
$ python -m pip install --user --upgrade virtualenv
42-
```
43-
- Linux (deb-based):
44-
```bash
45-
$ sudo apt-get update && sudo apt-get install \
46-
build-essential \
47-
libssl-dev \
48-
libffi-dev \
49-
python-dev \
50-
python-pip \
51-
python-setuptools \
52-
python-virtualenv -y
53-
```
54-
- Linux (rpm-based): See the pre-installation documentation for [RedHat/CentOS 6.x](docs/deploy-from-redhat-centos6.md) or [Fedora](docs/deploy-from-fedora-workstation.md)
55-
- Windows: See the [Windows documentation](docs/deploy-from-windows.md)
56-
57-
4. **Install Algo's remaining dependencies.** Use the same Terminal window as the previous step and run:
30+
The easiest way to get an Algo server running is to run it on your local system and let it set up a _new_ virtual machine in the cloud for you.
31+
32+
1. **Setup an account on a cloud hosting provider.** Algo supports [DigitalOcean](https://m.do.co/c/4d7f4ff9cfe4) (most user friendly), [Amazon Lightsail](https://aws.amazon.com/lightsail/), [Amazon EC2](https://aws.amazon.com/), [Vultr](https://www.vultr.com/), [Microsoft Azure](https://azure.microsoft.com/), [Google Compute Engine](https://cloud.google.com/compute/), [Scaleway](https://www.scaleway.com/), [DreamCompute](https://www.dreamhost.com/cloud/computing/) or other OpenStack-based cloud hosting, [Exoscale](https://www.exoscale.com) or other CloudStack-based cloud hosting, or [Hetzner Cloud](https://www.hetzner.com/).
33+
34+
2. **Get a copy of Algo.** The Algo scripts will be installed on your local system. There are two ways to get a copy:
35+
36+
- Download the [ZIP file](https://github.com/trailofbits/algo/archive/master.zip). Unzip the file to create a directory named `algo-master` containing the Algo scripts.
37+
38+
- Run the command `git clone https://github.com/trailofbits/algo.git` to create a directory named `algo` containing the Algo scripts.
39+
40+
3. **Install Algo's core dependencies.** Algo requires that **Python 3** and at least one supporting package are installed on your system.
41+
42+
- **macOS:** Apple does not provide Python 3 with macOS. There are two ways to obtain it:
43+
* Use the [Homebrew](https://brew.sh) package manager. After installing Homebrew install Python 3 by running `brew install python3`.
44+
45+
* Download and install the latest stable [Python 3 package](https://www.python.org/downloads/mac-osx/). Be sure to run the included *Install Certificates* command from Finder.
46+
47+
Once Python 3 is installed on your Mac, from Terminal run:
48+
```bash
49+
python3 -m pip install --upgrade virtualenv
50+
```
51+
52+
- **Linux:** Recent releases of Ubuntu, Debian, and Fedora come with Python 3 already installed. Make sure your system is up-to-date and install the supporting package(s):
53+
* Ubuntu and Debian:
54+
```bash
55+
sudo apt install -y python3-virtualenv
56+
```
57+
* Fedora:
58+
```bash
59+
sudo dnf install -y python3-virtualenv
60+
```
61+
* Red Hat and CentOS: See this [documentation](docs/deploy-from-redhat-centos6.md).
62+
63+
- **Windows:** Use the Windows Subsystem for Linux (WSL) to create your own copy of Ubuntu running under Windows from which to install and run Algo. See the [Windows documentation](docs/deploy-from-windows.md).
64+
65+
4. **Install Algo's remaining dependencies.** You'll need to run these commands from the Algo directory each time you download a new copy of Algo. In a Terminal window `cd` into the `algo-master` (ZIP file) or `algo` (`git clone`) directory and run:
5866
```bash
59-
$ python -m virtualenv --python=`which python2` env &&
60-
source env/bin/activate &&
61-
python -m pip install -U pip virtualenv &&
62-
python -m pip install -r requirements.txt
67+
python3 -m virtualenv --python="$(command -v python3)" .env &&
68+
source .env/bin/activate &&
69+
python3 -m pip install -U pip virtualenv &&
70+
python3 -m pip install -r requirements.txt
6371
```
64-
On macOS, you may be prompted to install `cc`. You should press accept if so.
72+
On Fedora add the option `--system-site-packages` to the first command above. On macOS install the C compiler if prompted.
6573

66-
5. **List the users to create.** Open `config.cfg` in your favorite text editor. Specify the users you wish to create in the `users` list. If you want to be able to add or delete users later, you **must** select `yes` for the `Do you want to retain the CA key?` prompt during the deployment. Make a unique user for each device you plan to setup.
74+
5. **List the users to create.** Open the file `config.cfg` in your favorite text editor. Specify the users you wish to create in the `users` list. Create a unique user for each device you plan to connect to your VPN. If you want to be able to add or delete users later, you **must** select `yes` at the `Do you want to retain the keys (PKI)?` prompt during the deployment.
6775

68-
6. **Start the deployment.** Return to your terminal. In the Algo directory, run `./algo` and follow the instructions. There are several optional features available. None are required for a fully functional VPN server. These optional features are described in greater detail in [deploy-from-ansible.md](docs/deploy-from-ansible.md).
76+
6. **Start the deployment.** Return to your terminal. In the Algo directory, run `./algo` and follow the instructions. There are several optional features available. None are required for a fully functional VPN server. These optional features are described in greater detail in [here](docs/deploy-from-ansible.md).
6977

70-
That's it! You will get the message below when the server deployment process completes. You now have an Algo server on the internet. Take note of the p12 (user certificate) password and the CA key in case you need them later, **they will only be displayed this time**.
78+
That's it! You will get the message below when the server deployment process completes. Take note of the p12 (user certificate) password and the CA key in case you need them later, **they will only be displayed this time**.
7179
72-
You can now setup clients to connect it, e.g. your iPhone or laptop. Proceed to [Configure the VPN Clients](#configure-the-vpn-clients) below.
80+
You can now set up clients to connect to your VPN. Proceed to [Configure the VPN Clients](#configure-the-vpn-clients) below.
7381
7482
```
7583
"# Congratulations! #"
@@ -111,36 +119,13 @@ WireGuard is used to provide VPN services on Windows. Algo generates a WireGuard
111119

112120
Install the [WireGuard VPN Client](https://www.wireguard.com/install/#windows-7-8-81-10-2012-2016-2019). Import the generated `wireguard/<username>.conf` file to your device, then setup a new connection with it.
113121

114-
### Linux Network Manager Clients (e.g., Ubuntu, Debian, or Fedora Desktop)
115-
116-
Network Manager does not support AES-GCM. In order to support Linux Desktop clients, choose the "compatible" cryptography during the deploy process and use at least Network Manager 1.4.1. See [Issue #263](https://github.com/trailofbits/algo/issues/263) for more information.
117-
118-
### Linux strongSwan Clients (e.g., OpenWRT, Ubuntu Server, etc.)
119-
120-
Install strongSwan, then copy the included ipsec_user.conf, ipsec_user.secrets, user.crt (user certificate), and user.key (private key) files to your client device. These will require customization based on your exact use case. These files were originally generated with a point-to-point OpenWRT-based VPN in mind.
121-
122-
#### Ubuntu Server example
123-
124-
1. `sudo apt-get install strongswan libstrongswan-standard-plugins`: install strongSwan
125-
2. `/etc/ipsec.d/certs`: copy `<name>.crt` from `algo-master/configs/<server_ip>/ipsec/manual/<name>.crt`
126-
3. `/etc/ipsec.d/private`: copy `<name>.key` from `algo-master/configs/<server_ip>/ipsec/manual/<name>.key`
127-
4. `/etc/ipsec.d/cacerts`: copy `cacert.pem` from `algo-master/configs/<server_ip>/ipsec/manual/cacert.pem`
128-
5. `/etc/ipsec.secrets`: add your `user.key` to the list, e.g. `<server_ip> : ECDSA <name>.key`
129-
6. `/etc/ipsec.conf`: add the connection from `ipsec_user.conf` and ensure `leftcert` matches the `<name>.crt` filename
130-
7. `sudo ipsec restart`: pick up config changes
131-
8. `sudo ipsec up <conn-name>`: start the ipsec tunnel
132-
9. `sudo ipsec down <conn-name>`: shutdown the ipsec tunnel
122+
### Linux WireGuard Clients
133123

134-
One common use case is to let your server access your local LAN without going through the VPN. Set up a passthrough connection by adding the following to `/etc/ipsec.conf`:
124+
WireGuard works great with Linux clients. See [this page](docs/client-linux-wireguard.md) for an example of how to configure WireGuard on Ubuntu.
135125

136-
conn lan-passthrough
137-
leftsubnet=192.168.1.1/24 # Replace with your LAN subnet
138-
rightsubnet=192.168.1.1/24 # Replace with your LAN subnet
139-
authby=never # No authentication necessary
140-
type=pass # passthrough
141-
auto=route # no need to ipsec up lan-passthrough
126+
### Linux strongSwan IPsec Clients (e.g., OpenWRT, Ubuntu Server, etc.)
142127

143-
To configure the connection to come up at boot time replace `auto=add` with `auto=start`.
128+
Please see [this page](docs/client-linux-ipsec.md).
144129

145130
### Other Devices
146131

@@ -177,7 +162,7 @@ where `user` is either `root` or `ubuntu` as listed on the success message, and
177162
_If you chose to save the CA key during the deploy process,_ then Algo's own scripts can easily add and remove users from the VPN server.
178163
179164
1. Update the `users` list in your `config.cfg`
180-
2. Open a terminal, `cd` to the algo directory, and activate the virtual environment with `source env/bin/activate`
165+
2. Open a terminal, `cd` to the algo directory, and activate the virtual environment with `source .env/bin/activate`
181166
3. Run the command: `./algo update-users`
182167
183168
After this process completes, the Algo VPN server will contain only the users listed in the `config.cfg` file.

algo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
if [ -z ${VIRTUAL_ENV+x} ]
66
then
7-
ACTIVATE_SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/env/bin/activate"
7+
ACTIVATE_SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.env/bin/activate"
88
if [ -f "$ACTIVATE_SCRIPT" ]
99
then
1010
# shellcheck source=/dev/null

algo-showenv.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ elif [[ -f LICENSE && ${STAT} ]]; then
6868
fi
6969

7070
# The Python version might be useful to know.
71-
if [[ -x ./env/bin/python ]]; then
72-
./env/bin/python --version 2>&1
71+
if [[ -x ./.env/bin/python3 ]]; then
72+
./.env/bin/python3 --version 2>&1
7373
elif [[ -f ./algo ]]; then
74-
echo "env/bin/python not found: has 'python -m virtualenv ...' been run?"
74+
echo ".env/bin/python3 not found: has 'python3 -m virtualenv ...' been run?"
7575
fi
7676

7777
# Just print out all command line arguments, which are expected

ansible.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ host_key_checking = False
66
timeout = 60
77
stdout_callback = default
88
display_skipped_hosts = no
9+
force_valid_group_names = ignore
910

1011
[paramiko_connection]
1112
record_host_keys = False

config.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ pki_in_tmpfs: true
1818
# If True re-init all existing certificates. Boolean
1919
keys_clean_all: False
2020

21-
# Clean up cloud python environments
22-
clean_environment: false
23-
2421
# Deploy StrongSwan to enable IPsec support
2522
ipsec_enabled: true
2623

@@ -159,9 +156,12 @@ cloud_providers:
159156
size: nano_1_0
160157
image: ubuntu_18_04
161158
scaleway:
162-
size: START1-S
159+
size: DEV1-S
163160
image: Ubuntu Bionic Beaver
164161
arch: x86_64
162+
hetzner:
163+
server_type: cx11
164+
image: ubuntu-18.04
165165
openstack:
166166
flavor_ram: ">=512"
167167
image: Ubuntu-18.04

docs/client-linux-ipsec.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Linux strongSwan IPsec Clients (e.g., OpenWRT, Ubuntu Server, etc.)
2+
3+
Install strongSwan, then copy the included ipsec_user.conf, ipsec_user.secrets, user.crt (user certificate), and user.key (private key) files to your client device. These will require customization based on your exact use case. These files were originally generated with a point-to-point OpenWRT-based VPN in mind.
4+
5+
## Ubuntu Server example
6+
7+
1. `sudo apt-get install strongswan libstrongswan-standard-plugins`: install strongSwan
8+
2. `/etc/ipsec.d/certs`: copy `<name>.crt` from `algo-master/configs/<server_ip>/ipsec/manual/<name>.crt`
9+
3. `/etc/ipsec.d/private`: copy `<name>.key` from `algo-master/configs/<server_ip>/ipsec/manual/<name>.key`
10+
4. `/etc/ipsec.d/cacerts`: copy `cacert.pem` from `algo-master/configs/<server_ip>/ipsec/manual/cacert.pem`
11+
5. `/etc/ipsec.secrets`: add your `user.key` to the list, e.g. `<server_ip> : ECDSA <name>.key`
12+
6. `/etc/ipsec.conf`: add the connection from `ipsec_user.conf` and ensure `leftcert` matches the `<name>.crt` filename
13+
7. `sudo ipsec restart`: pick up config changes
14+
8. `sudo ipsec up <conn-name>`: start the ipsec tunnel
15+
9. `sudo ipsec down <conn-name>`: shutdown the ipsec tunnel
16+
17+
One common use case is to let your server access your local LAN without going through the VPN. Set up a passthrough connection by adding the following to `/etc/ipsec.conf`:
18+
19+
conn lan-passthrough
20+
leftsubnet=192.168.1.1/24 # Replace with your LAN subnet
21+
rightsubnet=192.168.1.1/24 # Replace with your LAN subnet
22+
authby=never # No authentication necessary
23+
type=pass # passthrough
24+
auto=route # no need to ipsec up lan-passthrough
25+
26+
To configure the connection to come up at boot time replace `auto=add` with `auto=start`.
27+
28+
## Notes on SELinux
29+
30+
If you use a system with SELinux enabled you might need to set appropriate file contexts:
31+
32+
````
33+
semanage fcontext -a -t ipsec_key_file_t "$(pwd)(/.*)?"
34+
restorecon -R -v $(pwd)
35+
````
36+
37+
See [this comment](https://github.com/trailofbits/algo/issues/263#issuecomment-328053950).

0 commit comments

Comments
 (0)