-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenvpn.yaml
More file actions
39 lines (38 loc) · 1.05 KB
/
openvpn.yaml
File metadata and controls
39 lines (38 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#cloud-config
package_upgrade: true
packages:
- fail2ban
- curl
users:
- name: vpn
# ssh_authorized_keys:
# - ssh-rsa ... Main computer
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo
shell: /bin/bash
write_files:
- path: /etc/fail2ban/jail.local
content: |
[DEFAULT]
# Ban hosts for one hour:
bantime = 3600
#
# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport
#
[sshd]
enabled = true
port = 4444
logpath = %(sshd_log)s
runcmd:
# Configure SSH and fail2ban
- sed -i -e '/^Port/s/^.*$/Port 4444/' /etc/ssh/sshd_config
- sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- sed -i -e '$aAllowUsers vpn' /etc/ssh/sshd_config
- service ssh restart
- service fail2ban restart
# Install OpenVPN
- wget git.io/vpn --no-check-certificate -O openvpn-install.sh && bash openvpn-install.sh
- cp /root/client.ovpn /home/vpn/client.ovpn
# Reboot system after finished
- shutdown --reboot now