# System authorization information
auth --enableshadow --passalgo=sha512
# Use graphical install
text
repo --name="AppStream" --mirrorlist="http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream"
repo --name="EPEL" --mirrorlist="https://mirrors.fedoraproject.org/metalink?repo=epel-8&arch=x86_64"
# Use network installation
url --mirrorlist="http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=BaseOS"
# Run the Setup Agent on first boot
firstboot --disable
ignoredisk --only-use=vda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Agree to EULA
eula --agreed
# Reboot after completing the installation
reboot

# Network information
network  --bootproto=dhcp --device=eth0 --ethtool="autoneg on" --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$kJIeWX4dyBYrrYOL$iMmUIn7dsZkqBs8Bi0orwQbghjJtk1N7z7BRkq9aUYhY1QN3oWAMuvhf3mgq/wanoqJ9Qcev4J5W3mDcRGK0L0
# System timezone
timezone Europe/Sofia --isUtc --nontp
# System bootloader configuration
bootloader --append="crashkernel=auto net.ifnames=0 biosdevname=0" --location=mbr --boot-drive=vda

# Partition clearing information
zerombr
clearpart --all --initlabel --drives=vda
# Disk partitioning information
part /boot --fstype="ext2" --ondisk=vda --size=512
part swap --fstype="swap" --ondisk=vda --size=2048
part / --fstype="xfs" --ondisk=vda --size=21264

%packages
@^minimal-environment
kexec-tools
bind
bind-chroot
bind-utils
tcpdump
traceroute
mc
telnet
vim
dnf-automatic
nmap
rpcbind
wget
ftp
lftp
rsync
policycoreutils-python-utils
unzip
zip
iptraf-ng
epel-release
bird
fail2ban
fail2ban-systemd
chrony
%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=10 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=10 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=10 --minquality=1 --notstrict --nochanges --notempty
%end

%post

echo "CRYPTO_POLICY='-oCiphers=chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes256-ctr -oMACs=hmac-sha2-512-etm@openssh.com,hmac-sha2-512,hmac-sha2-256-etm@openssh.com,hmac-sha2-256 -oGSSAPIKexAlgorithms=gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp384,ecdh-sha2-nistp521 -oHostKeyAlgorithms=ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519 -oPubkeyAcceptedKeyTypes=rsa-sha2-256,ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,rsa-sha2-512,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com'" > /etc/crypto-policies/back-ends/opensshserver.config

rm -f /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key.pub && ssh-keygen -t ecdsa -b 384 -f /etc/ssh/ssh_host_ecdsa_key -C '' -N '' >&/dev/null

sed -i "s/apply_updates = no/apply_updates = yes/g" /etc/dnf/automatic.conf

systemctl enable --now dnf-automatic.timer

systemctl enable named-chroot

systemctl enable --now fail2ban

cat << EOF >> /etc/fail2ban/jail.d/01-sshd.conf
[DEFAULT]
# Ban hosts for one hour:
bantime = 3600

[sshd]
enabled = true
EOF

echo "net.ipv4.tcp_timestamps = 0" > /etc/sysctl.d/01-tcp-timestamp.conf

sed -i 's/\#compress/compress/g' /etc/logrotate.conf

firewall-offline-cmd --zone=public --add-service=ospf
firewall-offline-cmd --zone=public --add-port=1025/tcp
firewall-offline-cmd --zone=public --add-icmp-block={timestamp-request,timestamp-reply}

semanage port -a -t ssh_port_t -p tcp 1025

sed -i "s/^#Port 22/Port 1025/g" /etc/ssh/sshd_config
sed -i "s/^PermitRootLogin yes/PermitRootLogin without-password/g" /etc/ssh/sshd_config
sed -i "s/^PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config

sed -i 's/^#allow 192.168.0.0\/16/allow 62.44.96.0\/19\nallow 2001:67c:20d0::\/47/g' /etc/chrony.conf
sed -i "s/^pool 2.centos.pool.ntp.org iburst/server ntp0.nl.net iburst\nserver ntp1.nl.net iburst\nserver ntp2.nl.net iburst\nserver ntp0.ipv6.fau.de iburst\nserver ntp1.ipv6.fau.de iburst\nserver ntp2.ipv6.fau.de iburst\nserver ntp3.ipv6.fau.de iburst\nserver ntps1-0.uni-erlangen.de iburst\nserver ntps1-1.uni-erlangen.de iburst\nserver ntps1-2.uni-erlangen.de iburst/" /etc/chrony.conf

systemctl enable chronyd

%end
