server_optimize

This commit is contained in:
simono41 2019-08-05 13:43:33 +02:00
parent 31cc01779a
commit 53037fb233

View file

@ -5,6 +5,14 @@ set -ex
version="${1}" version="${1}"
[[ -z "${version}" ]] && version="${hostname#*-}" [[ -z "${version}" ]] && version="${hostname#*-}"
# while-schleife
while (( "$#" ))
do
echo ${1}
export ${1}="y"
shift
done
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2 echo "This script must be run as root" 1>&2
sudo "$0" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" sudo "$0" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
@ -14,6 +22,8 @@ else
fi fi
echo "Als root Angemeldet" echo "Als root Angemeldet"
sleep 5
function makesshsecure() { function makesshsecure() {
#sshd -T |grep permitrootlogin #sshd -T |grep permitrootlogin
@ -53,7 +63,12 @@ function makefail2ban() {
} }
function makeuser() { function makeuser() {
if ! cat /etc/group | grep wheel; then
groupadd wheel
fi
echo "root ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
echo "%wheel ALL=(ALL)" >> /etc/sudoers echo "%wheel ALL=(ALL)" >> /etc/sudoers
adduser user1
adduser user1 wheel adduser user1 wheel
} }
@ -88,14 +103,21 @@ function dailyupdates() {
} }
if [ "${makesshsecure}" == "y" ] || [ "${all}" == "y" ]; then
makesshsecure makesshsecure
sleep 1 fi
if [ "${makeiptables}" == "y" ] || [ "${all}" == "y" ]; then
makeiptables makeiptables
sleep 1 fi
if [ "${makefail2ban}" == "y" ] || [ "${all}" == "y" ]; then
makefail2ban makefail2ban
sleep 1 fi
if [ "${makeuser}" == "y" ] || [ "${all}" == "y" ]; then
makeuser makeuser
sleep 1 fi
if [ "${userloginalert}" == "y" ] || [ "${all}" == "y" ]; then
userloginalert userloginalert
sleep 1 fi
if [ "${dailyupdates}" == "y" ] || [ "${all}" == "y" ]; then
dailyupdates dailyupdates
fi