Skip to content

Instantly share code, notes, and snippets.

@matt-hensley
Last active January 11, 2016 15:25
Show Gist options
  • Save matt-hensley/d86c279aa66a5aa5ee30 to your computer and use it in GitHub Desktop.
Save matt-hensley/d86c279aa66a5aa5ee30 to your computer and use it in GitHub Desktop.
Ansible sshd/ufw
---
- hosts: all
tasks:
- ufw: rule=allow port={{ item.port }} proto={{ item.proto }}
with_items:
- { port: 22, proto: tcp }
- { port: 80, proto: tcp }
- { port: 8080, proto: tcp }
- { port: 1953, proto: tcp }
- ufw: policy=deny state=enabled
- name: Disable SSH password auth
lineinfile: destfile=/etc/ssh/sshd_config regexp="^(#)?PasswordAuthentication" line="PasswordAuthentication no" state=present
notify:
- restart ssh
handlers:
- name: restart ssh
service: name=ssh state=restarted enabled=yes
- name: restart fail2ban
service: name=fail2ban state=restarted
- name: reload fail2ban
service: name=fail2ban state=reloaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment