diff --git a/cloud-init b/cloud-init new file mode 100644 index 0000000..6edf018 --- /dev/null +++ b/cloud-init @@ -0,0 +1,15 @@ +#cloud-config +users: + - name: kk + groups: users, admin + sudo: ALL=(ALL) NOPASSWD:ALL + shell: /bin/bash + ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDlRnEXhUu2ObVokroMosX0k0xIdpFTdo2d15MmJYnTBPzDtAl7H1JLt5uthhsvfVYNjxncHn6EoSom+yhH3NhZiapunqtqLgd1QXpBdp3nWiyXFT9OPZRnZaeZxho/kFj5w8EAzPejQOHiqmqzI86yMM0sIPC4yOOBxltryevO8YhFRz8QVcU3RAQakUKa0mmewbrF+wJp/FpoYICSzd3plTHcBs7L6uUqz49y3Ut+Lwaf5/YQ7Zc+oXWLIzVxlR4nneWB8ltcOEscRaRE+oChsziZ+5GgG5yeD7TvgOBlAUQxnk02gA1A2yiiCFuTSew2DriKZoSqDa28oyKuFLid2NOJn9V+bMREWkHa1lk7i8RUz6H3ugqv0TLHv0+grbKDrCf8yWrRp+EVb4Zb3WOdoROkPmn01lHKrsNMOuBBcFgmMKDl6+AQ4vtwAFl6q9GyTMnnkTgK1fJlzsfQPXCcABELVWbodFsvHfJdggEVTo39T4p3jReip/QdzAIvuYbRLDwi33M8M3fyLhaEAMxHuO6DQ5ZHEz+cqL9EP700nUsfi4Rh5wG0LdiCFmGrUr85/K1ni0N2cb4RT6PhxAuM6bUUvYJykhT5a5NiyR/ytjR5HsW0S+V+dli4IZkr3+uVngWEUCB4Tai9VFlzYkGTYCSNwLEI3rZ3KtLZ480nxw== jakkon6@st.amu.edu.pl +packages: + - fail2ban + - ufw +package_update: true +package_upgrade: true +runcmd: + - [ sh, c, "$(wget -O- https://git.wmi.amu.edu.pl/s470607/code-server-test/src/branch/master/setup.sh)" ] diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..a1971da --- /dev/null +++ b/setup.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +touch /etc/testowy.plik + + +printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local +systemctl enable fail2ban +ufw allow OpenSSH +ufw enable +sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config +sed -i -e '/^PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config +sed -i -e '/^X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config +sed -i -e '/^#MaxAuthTries/s/^.*$/MaxAuthTries 2/' /etc/ssh/sshd_config +sed -i -e '/^#AllowTcpForwarding/s/^.*$/AllowTcpForwarding no/' /etc/ssh/sshd_config +sed -i -e '/^#AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config +sed -i -e '/^#AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config +sed -i '$a AllowUsers holu' /etc/ssh/sshd_config +reboot +