#!/bin/bash
# Opdatere serveren.
RED=”\033[1;31m”
GREEN=”\033[1;32m”
NOCOLOR=”\033[0m”
echo
echo -e “step 1: ${GREEN}update apt cache${NOCOLOR}”
sudo dnf update -y
echo
echo -e “step 2: ${GREEN}upgrade packages${NOCOLOR}”
sudo dnf upgrade -y
echo
echo -e “step 3: ${GREEN}clean up${NOCOLOR}”
sudo dnf autoremove -y
echo
# Sætte hostname på maskine (FQDN).
echo -e “step 1: ${GREEN}setting up new hostname${NOCOLOR}”
sudo hostnamectl set-hostname www.ton.local
echo
echo -e “step 2: ${GREEN}the new hostname${NOCOLOR}”
sudo hostname
echo
#Oprette brugeren pingu
echo -e “step 1: ${GREEN}adding a new user and setting a new password${NOCOLOR}”
sudo useradd pingu; echo ‘Pa$$w0rd’ | passwd –stdin pingu
echo
#Tilføjer til Sudo group
sudo usermod –aG wheel pingu
echo
#Ændre SELinux til permissive (brug sed med følgende kommando).
dnf install nano -y
sed -i ‘s/SELINUX=enforcing/SELINUX=permissive/g’ /etc/selinux/config
#Fjerne muligheden for root at logge ind via ssh (brug sed ).
sed -i ‘s/#PermitRootLogin prohibit-password/PermitRootLogin no/g’ /etc/ssh/sshd_config
#Tillade brugeren pingu at logge ind via ssh.
echo ‘AllowUsers pingu’ >> /etc/ssh/sshd_config
firewall-cmd –new-zone=secure –permanent
firewall-cmd –add-service=ssh –zone=secure –permanent
firewall-cmd –add-source=10.10.100.19 –zone=secure –permanent
firewall-cmd –remove-service=ssh –zone=internal –permanent
firewall-cmd –change-interface=enp1s0 –zone=internal –permanent
firewall-cmd –reload
#Genstart – som det sidste.
sudo reboot
Note:
Setup af vores system:
Download Excel fil her -> IP Plan for Linux
10.10.100.0/24, 255.255.255.0
router.ton.local = 10.10.100.1
storage.ton.local = 10.10.100.2
jump.ton.local = 10.10.100.19
Fysisk Maskine : Fedora 37 KDE Plasma
VM 1 : Router = CentOS 9 Stream
VM 2 : Storage = CentOS 9 Stream
VM 3 : Jump = CentOS 9 Stream
VM 4 : Gui = Fedora 37 Workstation
Se Part 1 her : https://tobiasnawaphol.dk/linux-router-jump-part-1/
Se Part 2 her : https://tobiasnawaphol.dk/linux-storage-fileserver-part-2/
Se Part 3 her : https://tobiasnawaphol.dk/linux-dns-opsaetning-part-3/
Se Part 4 her : https://tobiasnawaphol.dk/linux-database-webserver-part-4/
Links og kilder:
https://getfedora.org/
https://www.centos.org/download/
https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04
https://www.thegeekdiary.com/chcon-command-examples-in-linux/
https://ss64.com/bash/chmod.html
Hent dette indlæg i en PDF fil:
Download her ->