Skip to content

Commit

Permalink
add cloud hardening
Browse files Browse the repository at this point in the history
  • Loading branch information
ykim-1 committed Jan 8, 2024
1 parent 2cf4f3e commit 9d0f739
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quick-test/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
region: "{{ region }}"
image: linode/alpine3.18
booted: true
authorized_keys:
- "{{ lookup('file', ssh_pubkey_path) }}"
metadata:
user_data: '{{ lookup("template", playbook_dir ~ "/harden.yaml.j2") }}'
state: present
register: create_inst

Expand Down
36 changes: 36 additions & 0 deletions quick-test/harden.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#cloud-config
hostname: dx-dev-vm

package_update: true
package_upgrade: true
packages:
- fail2ban

ssh_pwauth: false
disable_root: true

users:
- default
- name: linodedx
gecos: The primary account for development on this VM.
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
lock_passwd: true
ssh_authorized_keys:
- '{{ ssh_pubkey }}'

write_files:
# Root login over SSH isn't fully disabled by disable_root
- path: /etc/ssh/sshd_config.d/51-disable-root.conf
permissions: "0600"
content: |
PermitRootLogin no

runcmd:
- service ssh restart
- service fail2ban start --enable

- ufw default deny incoming
- ufw default allow outgoing
- ufw allow 80,443,21,22/tcp
- ufw enable

0 comments on commit 9d0f739

Please sign in to comment.