#!/bin/bash -e #Set up iptables, disable root login and create unpriv user #User info is displayed at end of script and also saved as auth.txt #Usage: cp /usr/libexec/webmin/geohelm/scripts/secure-rhel.txt /opt/secure-rhel.sh #Usage: cp /opt #Usage: chmod +x secure-rhel.sh #Usage: ./secure-rhel.sh #Change user name below to something else! UNPRIV_USER='helmin' function install_iptables(){ cat >/etc/sysconfig/iptables <> /root/auth.txt fi sed -i.save 's/#\?Port [0-9]\+/Port 3824/' /etc/ssh/sshd_config sed -i.save 's/#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config systemctl restart sshd } touch /root/auth.txt yum install iptables-services service iptables start install_iptables; secure_ssh; echo "Passwords saved in /root/auth.txt" cat /root/auth.txt