8 Commits

Author SHA1 Message Date
113e72401e Licensing 2024-08-09 14:57:22 +02:00
23ad0ff277 Added loopback iptables rule 2024-08-02 11:12:46 +02:00
ee8242d842 Iptables persistence finally working 2024-08-02 10:38:36 +02:00
9ad7e73946 Removed login from usertwist 2024-08-02 10:10:40 +02:00
61705dd02f Fixed persistence (maybe...) 2024-08-02 09:59:26 +02:00
95d216ccd5 Added iptables folder 2024-08-02 09:45:14 +02:00
d41bfb5aad Fixed error on iptables_state package 2024-08-02 09:31:45 +02:00
daa4a1c745 Hardened usertwist service + Saved iptables rules 2024-08-02 09:27:48 +02:00
5 changed files with 37 additions and 23 deletions

View File

@@ -15,6 +15,7 @@ ProtectKernelModules=yes
ProtectControlGroups=yes
PrivateDevices=yes
RestrictSUIDSGID=true
ProtectHome=true
[Install]
WantedBy=multi-user.target

View File

@@ -38,6 +38,7 @@
name: usertwist
group: usertwist
system: true
shell: /usr/sbin/nologin
- name: Put the service binary on the remote server
ansible.builtin.copy:

View File

@@ -1,31 +1,14 @@
Role Name
Setup IPTables
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Create iptables rules on the remote server to allow connection on WEB and SSH ports only
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
- setup_iptables
License
-------
@@ -35,4 +18,5 @@ BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
Motysten
E-Mail : mdm@athelas.fr

View File

@@ -14,7 +14,7 @@ galaxy_info:
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
license: MIT
min_ansible_version: 2.1

View File

@@ -11,7 +11,35 @@
- "443"
- "80"
- name: Accept connection on lo (for Caddy <-> usertwist communication)
ansible.builtin.iptables:
chain: INPUT
protocol: tcp
in_interface: lo
jump: ACCEPT
- name: Set INPUT policy to DROP
ansible.builtin.iptables:
chain: INPUT
policy: DROP
policy: DROP
- name: Create iptables folder in /etc
ansible.builtin.file:
path: /etc/ansible
state: directory
mode: '0755'
- name: Install iptables-persistent for rules persistence
ansible.builtin.package:
name: iptables-persistent
update_cache: true
- name: Save IPv4 rules to keep them on reboot
community.general.iptables_state:
state: saved
path: /etc/iptables/rules.v4
- name: Save IPv6 rules to keep them on reboot
community.general.iptables_state:
state: saved
path: /etc/iptables/rules.v6