cfn-vpn 0.5.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-gem.yml +25 -0
- data/.github/workflows/release-gem.yml +31 -0
- data/.github/workflows/release-image.yml +33 -0
- data/Gemfile.lock +30 -38
- data/README.md +1 -247
- data/cfn-vpn.gemspec +3 -2
- data/docs/README.md +44 -0
- data/docs/certificate-users.md +89 -0
- data/docs/getting-started.md +87 -0
- data/docs/modifying.md +67 -0
- data/docs/routes.md +82 -0
- data/docs/scheduling.md +32 -0
- data/docs/sessions.md +27 -0
- data/lib/cfnvpn.rb +31 -27
- data/lib/cfnvpn/{client.rb → actions/client.rb} +5 -6
- data/lib/cfnvpn/{embedded.rb → actions/embedded.rb} +15 -15
- data/lib/cfnvpn/actions/init.rb +130 -0
- data/lib/cfnvpn/actions/modify.rb +149 -0
- data/lib/cfnvpn/actions/params.rb +73 -0
- data/lib/cfnvpn/{revoke.rb → actions/revoke.rb} +6 -6
- data/lib/cfnvpn/actions/routes.rb +144 -0
- data/lib/cfnvpn/{sessions.rb → actions/sessions.rb} +5 -5
- data/lib/cfnvpn/{share.rb → actions/share.rb} +10 -10
- data/lib/cfnvpn/actions/subnets.rb +78 -0
- data/lib/cfnvpn/certificates.rb +5 -5
- data/lib/cfnvpn/clientvpn.rb +34 -68
- data/lib/cfnvpn/compiler.rb +23 -0
- data/lib/cfnvpn/config.rb +34 -78
- data/lib/cfnvpn/{cloudformation.rb → deployer.rb} +47 -19
- data/lib/cfnvpn/log.rb +26 -26
- data/lib/cfnvpn/s3.rb +4 -4
- data/lib/cfnvpn/string.rb +29 -0
- data/lib/cfnvpn/templates/helper.rb +14 -0
- data/lib/cfnvpn/templates/vpn.rb +344 -0
- data/lib/cfnvpn/version.rb +1 -1
- metadata +55 -22
- data/lib/cfnvpn/cfhighlander.rb +0 -49
- data/lib/cfnvpn/init.rb +0 -109
- data/lib/cfnvpn/modify.rb +0 -103
- data/lib/cfnvpn/routes.rb +0 -84
- data/lib/cfnvpn/templates/cfnvpn.cfhighlander.rb.tt +0 -27
data/cfn-vpn.gemspec
CHANGED
@@ -37,13 +37,14 @@ Gem::Specification.new do |spec|
|
|
37
37
|
|
38
38
|
spec.add_dependency "thor", "~> 0.20"
|
39
39
|
spec.add_dependency "terminal-table", '~> 1', '<2'
|
40
|
-
spec.add_dependency '
|
40
|
+
spec.add_dependency 'cfndsl', '~> 1', '<2'
|
41
41
|
spec.add_dependency 'netaddr', '2.0.4'
|
42
42
|
spec.add_runtime_dependency 'aws-sdk-ec2', '~> 1.95', '<2'
|
43
43
|
spec.add_runtime_dependency 'aws-sdk-acm', '~> 1', '<2'
|
44
44
|
spec.add_runtime_dependency 'aws-sdk-s3', '~> 1', '<2'
|
45
45
|
spec.add_runtime_dependency 'aws-sdk-cloudformation', '~> 1', '<2'
|
46
|
+
spec.add_runtime_dependency 'aws-sdk-ssm', '~> 1', '<2'
|
46
47
|
|
47
48
|
spec.add_development_dependency "bundler", "~> 2.0"
|
48
|
-
spec.add_development_dependency "rake", "~>
|
49
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
49
50
|
end
|
data/docs/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# CfnVpn for AWS Client-VPN
|
2
|
+
|
3
|
+
`cfn-vpn` is a wrapper around [AWS Client-VPN](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/what-is.html) to improve the management experience of the VPN. The tool utilises Cloudformation to manage the AWS resources required by the Client-VPN and automates the certificate management process with the [openvpn/easy-rsa](https://github.com/OpenVPN/easy-rsa) library.
|
4
|
+
|
5
|
+
## VPN Scenarios
|
6
|
+
|
7
|
+
For further AWS documentation please visit https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/scenario.html
|
8
|
+
|
9
|
+
### Split Tunnel
|
10
|
+
|
11
|
+
Split tunnel when enabled will only push the routes defined on the client vpn. This is useful if you only want to push routes from your vpc through the vpn.
|
12
|
+
|
13
|
+
### Public Subnet with Internet Access
|
14
|
+
|
15
|
+
This can be setup with default options selected. This will push all routes from through the vpn including all internet traffic. The ENI attached to the vpn client attaches a public IP which is used for natting between the vpn and the internet. This must be placed inside a public subnet with a internet gateway attached to the vpc.
|
16
|
+
Please read the AWS [documentation](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/scenario-internet.html) for troubleshooting any networking issues
|
17
|
+
|
18
|
+
### Private Subnet with Internet Access
|
19
|
+
|
20
|
+
This is the same as above but the vpn attached to a subnet in a private subnet with the public route being routed through a nat gateway. **NOTE** the dns on the vpn must be set to the dns server of the vpc you've attached the vpn to, the reserved IP address at the base of the VPC IPv4 network range plus two. For example if you VPC cidr is 10.0.0.0/16 then the dns server for that vpc is 10.0.0.2.
|
21
|
+
|
22
|
+
```bash
|
23
|
+
cfn-vpn init myvpn --bucket mybucket --server-cn myvpn.domain.tld --subnet-id subnet-123456ab --dns-servers 10.0.0.2
|
24
|
+
```
|
25
|
+
|
26
|
+
If you are experiencing issue connecting to the internet check to see if your local dns configurations are overriding the ones set by the vpn. You can test this by using `dig` to query a domain from the vpc dns server. For example:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
dig @10.0.0.2 google.com
|
30
|
+
```
|
31
|
+
|
32
|
+
## Authentication Types
|
33
|
+
|
34
|
+
`cfn-vpn` supports certificate and federated type authentication for AWS Client-VPN. It currently doesn't support Active Directory type authentication.
|
35
|
+
For further information on the authentication types please visit https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/client-authentication.html
|
36
|
+
|
37
|
+
## CfnVpn Documentation
|
38
|
+
|
39
|
+
1. [Getting Started](getting-started.md)
|
40
|
+
2. [Modifying The Client-VPN](modifying.md)
|
41
|
+
3. [Managing Certificate Users](certificate-users.md)
|
42
|
+
4. [Managing Routes](routes.md)
|
43
|
+
5. [Stop and Start Client-VPN](scheduling.md)
|
44
|
+
6. [Managing Sessions](sessions.md)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Managing Certificate Authenticated Users
|
2
|
+
|
3
|
+
This section explains how to generate, revoke VPN clients and share config the config with the users
|
4
|
+
|
5
|
+
## Create a new user
|
6
|
+
|
7
|
+
This will generate a new client certificate and key against the CA generated in the `init`.
|
8
|
+
It will be bundled into a tar and stored encrypted in your provided s3 bucket.
|
9
|
+
|
10
|
+
```
|
11
|
+
cfn-vpn client myvpn --client-cn user1 --bucket mybucket
|
12
|
+
```
|
13
|
+
|
14
|
+
|
15
|
+
## Revoke a user
|
16
|
+
|
17
|
+
This will revoke the client certificate and apply to the client VPN endpoint.
|
18
|
+
Note this wont terminate the session but will stop the client from reconnecting using the certificate.
|
19
|
+
|
20
|
+
```sh
|
21
|
+
cfn-vpn revoke myvpn --client-cn user1 --bucket mybucket
|
22
|
+
```
|
23
|
+
|
24
|
+
## Modify the Client VPN config
|
25
|
+
|
26
|
+
This will modify some attributes of the client vpn endpoint.
|
27
|
+
|
28
|
+
```sh
|
29
|
+
cfn-vpn config myvpn --dns-servers 8.8.8.8 8.8.4.4
|
30
|
+
```
|
31
|
+
|
32
|
+
*Options:*
|
33
|
+
|
34
|
+
```bash
|
35
|
+
[--cidr=CIDR] # cidr from which to assign client IP addresses
|
36
|
+
# Default: 10.250.0.0/16
|
37
|
+
[--dns-servers=DNS_SERVERS] # DNS Servers to push to clients.
|
38
|
+
[--split-tunnel], [--no-split-tunnel] # only push routes to the client on the vpn endpoint
|
39
|
+
[--internet-route], [--no-internet-route] # create a default route to the internet
|
40
|
+
# Default: true
|
41
|
+
[--protocol=PROTOCOL] # set the protocol for the vpn connections
|
42
|
+
# Default: udp
|
43
|
+
# Possible values: udp, tcp
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
## Share client certificates with a user
|
48
|
+
|
49
|
+
The users vpn config and certificates can be passed to the user securely using S3 signed URLs to allow the user to directly download them.
|
50
|
+
There are 2 ways to generate the vpn config file, by having the certificates and config file separate or by embedding the certificates into the config file.
|
51
|
+
|
52
|
+
|
53
|
+
### Certificate embedded into config
|
54
|
+
|
55
|
+
This will pull the clients certificate and key archives from S3 and embed them into the config file, upload it back to S3 and generate a presigned URL for the user.
|
56
|
+
This allows the you to download or share a single, ready to import config file into a OpenVPN client.
|
57
|
+
|
58
|
+
```sh
|
59
|
+
cfn-vpn embedded myvpn --client-cn user1 --bucket mybucket
|
60
|
+
```
|
61
|
+
|
62
|
+
### Separate certificate and config
|
63
|
+
|
64
|
+
This will generate a presigned url for the client's certificate and config file to allow them to download them to their local computer.
|
65
|
+
|
66
|
+
```sh
|
67
|
+
cfn-vpn share myvpn --client-cn user1 --bucket mybucket
|
68
|
+
```
|
69
|
+
|
70
|
+
You can then share the output with your user
|
71
|
+
|
72
|
+
```
|
73
|
+
Download the certificates and config from the bellow presigned URLs which will expire in 1 hour.
|
74
|
+
|
75
|
+
Certificate:
|
76
|
+
<presigned url>
|
77
|
+
|
78
|
+
Config:
|
79
|
+
<presigned url>
|
80
|
+
|
81
|
+
Extract the certificates from the tar and place into a safe location.
|
82
|
+
tar xzfv user1.tar.gz -C <path>
|
83
|
+
|
84
|
+
Modify base2-ciinabox.config.ovpn to include the full location of your extracted certificates
|
85
|
+
echo "key /<path>/user1.key" >> myvpn.config.ovpn
|
86
|
+
echo "cert /<path>/user1.crt" >> myvpn.config.ovpn
|
87
|
+
|
88
|
+
Open myvpn.config.ovpn with your favourite openvpn client.
|
89
|
+
```
|
@@ -0,0 +1,87 @@
|
|
1
|
+
## Getting Started with CfnVpn
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Install `cfn-vpn` gem
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install cfn-vpn --source "https://rubygems.pkg.github.com/base2services"
|
9
|
+
```
|
10
|
+
|
11
|
+
## Setup Easy-RSA
|
12
|
+
|
13
|
+
**Option 1 - Docker**
|
14
|
+
|
15
|
+
Install [docker](https://docs.docker.com/install/)
|
16
|
+
|
17
|
+
Docker is required to generate the certificates required for the client vpn.
|
18
|
+
The gem uses [openvpn/easy-rsa](https://github.com/OpenVPN/easy-rsa) project in [base2/aws-client-vpn](https://hub.docker.com/r/base2/aws-client-vpn) docker image. [repo](https://github.com/base2Services/ciinabox-containers/tree/master/easy-rsa)
|
19
|
+
|
20
|
+
**Option 2 - local**
|
21
|
+
|
22
|
+
If you would rather setup easy-rsa than install docker, you can use the `--easyrsa-local` flag when running the commands to use a local copy of easy-rsa, the binary just needs to be available in the `$PATH`. Install from [openvpn/easy-rsa](https://github.com/OpenVPN/easy-rsa)
|
23
|
+
|
24
|
+
|
25
|
+
## Setup Your AWS Credentials
|
26
|
+
|
27
|
+
Setup your [AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) by either setting a profile or exporting them as environment variables.
|
28
|
+
|
29
|
+
```bash
|
30
|
+
export AWS_ACCESS_KEY_ID="XXXXXXXXXXXXXXXXXXXXX"
|
31
|
+
export AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXX"
|
32
|
+
export AWS_SESSION_TOKEN="XXXXXXXXXXXXXXXXXXXXX"
|
33
|
+
```
|
34
|
+
|
35
|
+
Optionally export the AWS region if not providing `--region` flag
|
36
|
+
|
37
|
+
```bash
|
38
|
+
export AWS_REGION="us-east-1"
|
39
|
+
```
|
40
|
+
|
41
|
+
## Initialising CfnVpn
|
42
|
+
|
43
|
+
to launch a new CfnVpn stack run the `init` command along with the options.
|
44
|
+
|
45
|
+
### Certificate Authenticated VPN
|
46
|
+
|
47
|
+
The following command and required option will launch a new certificate based Client-VPN
|
48
|
+
|
49
|
+
```sh
|
50
|
+
cfn-vpn init [name] --bucket [s3-bucket] --server-cn [server certificate name] --subnet-ids [list of subets to associate with the vpn]
|
51
|
+
```
|
52
|
+
|
53
|
+
### Federated SAML Authenticated VPN
|
54
|
+
|
55
|
+
**Prerequisites:** Client-VPN requires a IAM SAML identity provider ARN, see the [AWS docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html) to create one.
|
56
|
+
|
57
|
+
The following command and required option will launch a new federated based Client-VPN
|
58
|
+
|
59
|
+
```sh
|
60
|
+
cfn-vpn init [name] --server-cn [server certificate name] --subnet-ids [list of subets to associate with the vpn] --saml-arn [identity providor arn]
|
61
|
+
```
|
62
|
+
|
63
|
+
## Additional Initialising Options
|
64
|
+
|
65
|
+
```
|
66
|
+
Options:
|
67
|
+
r, [--region=REGION] # AWS Region
|
68
|
+
# Default: ap-southeast-2
|
69
|
+
[--verbose], [--no-verbose] # set log level to debug
|
70
|
+
--server-cn=SERVER_CN # server certificate common name
|
71
|
+
[--client-cn=CLIENT_CN] # client certificate common name
|
72
|
+
[--easyrsa-local], [--no-easyrsa-local] # run the easyrsa executable from your local rather than from docker
|
73
|
+
[--bucket=BUCKET] # s3 bucket
|
74
|
+
--subnet-ids=one two three # subnet id to associate your vpn with
|
75
|
+
[--cidr=CIDR] # cidr from which to assign client IP addresses
|
76
|
+
# Default: 10.250.0.0/16
|
77
|
+
[--dns-servers=one two three] # DNS Servers to push to clients.
|
78
|
+
[--split-tunnel], [--no-split-tunnel] # only push routes to the client on the vpn endpoint
|
79
|
+
# Default: true
|
80
|
+
[--internet-route=INTERNET_ROUTE] # [subnet-id] create a default route to the internet through a subnet
|
81
|
+
[--protocol=PROTOCOL] # set the protocol for the vpn connections
|
82
|
+
# Default: udp
|
83
|
+
# Possible values: udp, tcp
|
84
|
+
[--start=START] # cloudwatch event cron schedule in UTC to associate subnets to the client vpn
|
85
|
+
[--stop=STOP] # cloudwatch event cron schedule in UTC to disassociate subnets to the client vpn
|
86
|
+
[--saml-arn=SAML_ARN] # IAM SAML idenditiy providor arn if using SAML federated authentication
|
87
|
+
```
|
data/docs/modifying.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Modifying The Client-VPN
|
2
|
+
|
3
|
+
The Client-VPN properties such as the DNS servers and the associated subnets can be modified using the `modify` command
|
4
|
+
|
5
|
+
|
6
|
+
## CfnVpn Configuration
|
7
|
+
|
8
|
+
By default `cfn-vpn` configuration is managed in a SSM parameter name `/cfnvpn/config/[name]`. This config can be dumped to a YAML file if you wish to manage through source control and use for updating `cfn-vpn` configuration.
|
9
|
+
|
10
|
+
to dump the config to a yaml file use the `params` command. this will create a file call `cfnvpn.[name].yaml` in your current directory
|
11
|
+
|
12
|
+
```sh
|
13
|
+
cfn-vpn params [name] --dump
|
14
|
+
```
|
15
|
+
|
16
|
+
the `params` command can also be used to view the current deployed config and diff the deployed config against your local yaml file
|
17
|
+
|
18
|
+
### View
|
19
|
+
|
20
|
+
```sh
|
21
|
+
cfn-vpn params [name]
|
22
|
+
```
|
23
|
+
|
24
|
+
### Diff
|
25
|
+
|
26
|
+
```sh
|
27
|
+
cfn-vpn params [name] --diff-yaml cfnvpn.[name].yaml
|
28
|
+
```
|
29
|
+
|
30
|
+
## Modifying
|
31
|
+
|
32
|
+
### With CLI Options
|
33
|
+
|
34
|
+
to modify the VPN properties run the modify command with the desired options
|
35
|
+
|
36
|
+
```
|
37
|
+
cfn-vpn modify [name] --dns-servers 10.15.0.2
|
38
|
+
```
|
39
|
+
|
40
|
+
a cloudformation changeset is created with the desired changes and approval is asked
|
41
|
+
|
42
|
+
```
|
43
|
+
INFO: - Creating cloudformation changeset for stack [name]-cfnvpn in [region]
|
44
|
+
|
45
|
+
+-----------------------------------+---------------------------------------------+-------------+---------------------+
|
46
|
+
| Modify |
|
47
|
+
+-----------------------------------+---------------------------------------------+-------------+---------------------+
|
48
|
+
| Logical Resource Id | Resource Type | Replacement | Changes |
|
49
|
+
+-----------------------------------+---------------------------------------------+-------------+---------------------+
|
50
|
+
| CfnVpnConfig | AWS::SSM::Parameter | Conditional | Value |
|
51
|
+
| ClientVpnEndpoint | AWS::EC2::ClientVpnEndpoint | Conditional | DnsServers |
|
52
|
+
| ClientVpnTargetNetworkAssociation | AWS::EC2::ClientVpnTargetNetworkAssociation | Conditional | ClientVpnEndpointId |
|
53
|
+
| TargetNetworkAuthorizationRule | AWS::EC2::ClientVpnAuthorizationRule | Conditional | ClientVpnEndpointId |
|
54
|
+
+-----------------------------------+---------------------------------------------+-------------+---------------------+
|
55
|
+
INFO: - Cloudformation changeset changes:
|
56
|
+
|
57
|
+
Continue? y
|
58
|
+
INFO: - Waiting for changeset to UPDATE
|
59
|
+
INFO: - Changeset UPDATE complete
|
60
|
+
INFO: - Client VPN [endpoint-id] modified
|
61
|
+
```
|
62
|
+
|
63
|
+
### With YAML File
|
64
|
+
|
65
|
+
```
|
66
|
+
cfn-vpn modify [name] --params-yaml cfnvpn.[name].yaml
|
67
|
+
```
|
data/docs/routes.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Managing Client-VPN Routes
|
2
|
+
|
3
|
+
Management of the VPN routes can be altered using the `routes` command or by using the `modify` command along with the yaml config file.
|
4
|
+
|
5
|
+
## Routes Command
|
6
|
+
|
7
|
+
```
|
8
|
+
Options:
|
9
|
+
r, [--region=REGION] # AWS Region
|
10
|
+
# Default: ap-southeast-2
|
11
|
+
[--verbose], [--no-verbose] # set log level to debug
|
12
|
+
[--cidr=CIDR] # cidr range
|
13
|
+
[--subnet=SUBNET] # the target vpc subnet to route through, if none is supplied the default subnet is used
|
14
|
+
[--desc=DESC] # description of the route
|
15
|
+
[--groups=one two three] # override all authorised groups on thr route
|
16
|
+
[--add-groups=one two three] # add authorised groups to an existing route
|
17
|
+
[--del-groups=one two three] # remove authorised groups from an existing route
|
18
|
+
[--delete], [--no-delete] # delete the route from the client vpn
|
19
|
+
|
20
|
+
List, add or delete client vpn routes
|
21
|
+
```
|
22
|
+
|
23
|
+
### Add New
|
24
|
+
|
25
|
+
to add a new route run the routes command along with the `--cidr` option
|
26
|
+
|
27
|
+
```sh
|
28
|
+
cfn-vpn routes [name] --cidr 10.151.0.0/16
|
29
|
+
```
|
30
|
+
|
31
|
+
### Delete
|
32
|
+
|
33
|
+
to delete a route run the routes command along with the `--cidr` option of the route to delete and the delete option
|
34
|
+
|
35
|
+
```sh
|
36
|
+
cfn-vpn routes [name] --cidr 10.151.0.0/16 --delete
|
37
|
+
```
|
38
|
+
|
39
|
+
### Manage Authorization Groups
|
40
|
+
|
41
|
+
When using federated authentication groups can be used to control access to certain routes. These can be managed on the routes by providing the `--groups [list of groups]` along with a space delimited list of groups to the `routes` command.
|
42
|
+
|
43
|
+
To add groups to a new route or to override all groups on an exiting route use the `--groups` options
|
44
|
+
|
45
|
+
```sh
|
46
|
+
cfn-vpn routes [name] --cidr 10.151.0.0/16 --groups devs ops
|
47
|
+
```
|
48
|
+
|
49
|
+
To add groups to an existing route use the `--add-groups` options
|
50
|
+
|
51
|
+
```sh
|
52
|
+
cfn-vpn routes [name] --cidr 10.151.0.0/16 --add-groups admin
|
53
|
+
```
|
54
|
+
|
55
|
+
To delete groups from an existing route use the `--del-groups` options
|
56
|
+
|
57
|
+
```sh
|
58
|
+
cfn-vpn routes [name] --cidr 10.151.0.0/16 --del-groups dev
|
59
|
+
```
|
60
|
+
|
61
|
+
## Modify Command
|
62
|
+
|
63
|
+
add or modify the `routes:` key in your config yaml file
|
64
|
+
|
65
|
+
```yaml
|
66
|
+
routes:
|
67
|
+
- cidr: 10.151.0.0/16
|
68
|
+
desc: route to dev peered vpc
|
69
|
+
groups:
|
70
|
+
- devs
|
71
|
+
- ops
|
72
|
+
- cidr: 10.152.0.0/16
|
73
|
+
desc: route to prod peered vpc
|
74
|
+
groups:
|
75
|
+
- ops
|
76
|
+
```
|
77
|
+
|
78
|
+
run the `modify` command and supply the yaml file to apply the changes
|
79
|
+
|
80
|
+
```sh
|
81
|
+
cfn-vpn routes [name] --params-yaml cfnvpn.[name].yaml
|
82
|
+
```
|
data/docs/scheduling.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Stop and Start Client-VPN
|
2
|
+
|
3
|
+
Stopping and starting the VPN can help save AWS costs when you're not using the VPN. AWS pricing model for Client-VPN is per associated subnet per hour so we can achieve this by disassociating the subnets when the VPN is not required and the associated them again when required.
|
4
|
+
|
5
|
+
This can be achieved through `cfn-vpn` in 2 ways, by a cli command or via a cloudwatch event schedule.
|
6
|
+
|
7
|
+
## CLI Command
|
8
|
+
|
9
|
+
Use the following commands to stop and start your Client-VPN
|
10
|
+
|
11
|
+
### Disassociate
|
12
|
+
|
13
|
+
```sh
|
14
|
+
cfn-vpn subnets [name] --disassociate
|
15
|
+
```
|
16
|
+
|
17
|
+
### Associate
|
18
|
+
|
19
|
+
```sh
|
20
|
+
cfn-vpn subnets [name] --associate
|
21
|
+
```
|
22
|
+
|
23
|
+
## Schedule
|
24
|
+
|
25
|
+
A CloudWatch cron schedule with a lambda function can be setup to stop and start your Client-VPN. This can be achieved by modifying the `cfn-vpn` stack with the required cron schedules.
|
26
|
+
To see the CloudWatch cron syntax please visit the [AWS docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions) for further info
|
27
|
+
|
28
|
+
```sh
|
29
|
+
cfn-vpn modify [name] --stop "10 6 * * ? *" --start "00 20 ? * MON-FRI *"
|
30
|
+
```
|
31
|
+
|
32
|
+
One or both of `--start` and `--stop` can be supplied, for example if you wanted an on demand start with a scheduled stop.
|
data/docs/sessions.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Managing Client-VPN Sessions
|
2
|
+
|
3
|
+
## Show Sessions
|
4
|
+
|
5
|
+
This is show a table of current connections on the vpn. You can then kill sessions by using the connection id.
|
6
|
+
|
7
|
+
```sh
|
8
|
+
cfn-vpn sessions [name]
|
9
|
+
```
|
10
|
+
|
11
|
+
The sessions are displayed in a table format
|
12
|
+
|
13
|
+
```bash
|
14
|
+
+-------------+---------------------+--------+-------------+-----------------------------------+---------------+--------------+
|
15
|
+
| Common Name | Connected (UTC) | Status | IP Address | Connection ID | Ingress Bytes | Egress Bytes |
|
16
|
+
+-------------+---------------------+--------+-------------+-----------------------------------+---------------+--------------+
|
17
|
+
| user1 | 2019-06-28 04:58:19 | active | 10.250.0.98 | cvpn-connection-05bcc579cb3fdf9a3 | 3000 | 2679 |
|
18
|
+
+-------------+---------------------+--------+-------------+-----------------------------------+---------------+--------------+
|
19
|
+
```
|
20
|
+
|
21
|
+
## Terminate a Session
|
22
|
+
|
23
|
+
To terminate a Client-VPN session specify the `--kill` flag with the connection id to kill the session.
|
24
|
+
|
25
|
+
```sh
|
26
|
+
cfn-vpn sessions myvpn --kill cvpn-connection-05bcc579cb3fdf9a3
|
27
|
+
```
|