This terraform repository creates OpenVPN-servers on virtual Linux servers on Linode.
This project require these programs to run:
- OpenSSH
- Terraform
- Ansible
You must also have generated an SSH key for your computer. As of 2021-05-26 it has to use the RSA algorithm, not ED25519.
You must also have created an account on Linode as well as generated an API Token for your account.
To configure your environment you need to create a file named terraform.tfvars
. This is where you will override all variables defined in variables.tf
.
Example - terraform.tfvars
# Provisioning
token = "<YOUR LINODE API KEY>"
download_dir = "~/Path/To/VPN/Folder/"
# Public keys
public_keys = {
laptop_key = "<YOUR PUBLIC SSH KEY>"
pc_key = "<YOUR PUBLIC SSH KEY>"
}
vpn_regions = {
vpn-us = {
linode_region = "us-east"
type = "g6-nanode-1"
image = "linode/ubuntu20.04"
},
vpn-uk = {
linode_region = "eu-west"
type = "g6-nanode-1"
image = "linode/ubuntu20.04"
}
}
Now that you've created your configuration, it's time to create your servers.
- Open the root folder (containing this
README.md
) in a terminal. - Run
terraform init
to initialize this terraform project - Run
terraform plan
to check your configuration - If all is clear, run
terraform apply
to start the provisioning.
When these commands are run the above configuration in terraform.tfvars
will create 2 virtual VPN-servers, upload laptop_key
and pc_key
as authorized keys for SSH login and download the VPN client files (vpn-us.ovpn
and vpn-uk.ovpn
) to ~/Path/To/VPN/Folder/
.
And boom! Now you have your own VPN-servers.
Your Linode API token used to access your resources at Linode.
Path to your private SSH key file.
Default: "~/.ssh/id_rsa"
Path to a directory on your coputer to which all VPN-client files will be downloaded.
Default: "~/vpn/"
A map of public ssh keys to add to authorized_keys on your VPN-servers.
Example:
public_keys = {
laptop_key = "<YOUR PUBLIC SSH KEY>"
pc_key = "<YOUR PUBLIC SSH KEY>"
}
A map containing configurations for the VPN servers to create:
- linode_region: the VPN server's Linode data center region.
- type: the Linode server type
- image: Linux image to install on server
Example:
vpn_regions = {
vpn-us = {
linode_region = "us-east"
type = "g6-nanode-1"
image = "linode/ubuntu20.04"
},
vpn-uk = {
linode_region = "eu-west"
type = "g6-nanode-1"
image = "linode/ubuntu20.04"
}
}