---
# System prepended metadata

title: Kickstart File Template for Automating Installation of RHEL 8

---

# Kickstart File Template for Automating Installation of RHEL 8

Useful when mass deploying RHEL 8.

## `ks.cfg`

* Replace all occurrences of `FILL_IN_HERE` with desired values.
* Double-check partition scheme. (**WARNING**: First and second disks will be wiped out!)
* Double-check network configuration.
* Double-check package selection.

```=
#version=RHEL8

# cdrom
# harddrive --partition= --dir=
# nfs       --server=    --dir=
# url       --url=       --noverifyssl
cdrom
eula --agreed
firstboot --disable
graphical
# text
skipx
reboot

keyboard --xlayouts=us
lang       en_US.UTF-8
timezone --ntpservers=clock.stdtime.gov.tw,tick.stdtime.gov.tw,time.stdtime.gov.tw,tock.stdtime.gov.tw,watch.stdtime.gov.tw Asia/Taipei

rootpw --plaintext FILL_IN_HERE
user   --gid=9999 --uid=9999 --groups=wheel --name=FILL_IN_HERE --gecos="FILL_IN_HERE" --password=FILL_IN_HERE --plaintext
sshkey --username=root         "FILL_IN_HERE"
sshkey --username=FILL_IN_HERE "FILL_IN_HERE"

bootloader --boot-drive=sda --location=mbr
clearpart  --all --drives=sda|sdb --disklabel=gpt --initlabel
ignoredisk --only-use=sda|sdb
zerombr

part /boot/efi --fstype=efi  --label=efis --ondisk=sda --size=256
part /boot     --fstype=xfs  --label=boot --ondisk=sda --size=1024
part pv.1                                 --ondisk=sda --size=9216 --grow
volgroup linux pv.1
# logvol swap    --fstype=swap --label=swap              --size=1024 --name=swap --vgname=linux
logvol /home   --fstype=xfs  --label=home              --size=4096 --name=home --vgname=linux
logvol /       --fstype=xfs  --label=root              --size=4096 --name=root --vgname=linux --grow

network --activate --bootproto=static --device=eth0 --gateway=172.16.0.1 --ip=172.16.0.2 --ipv6=auto --nameserver=192.168.1.1 --netmask=255.255.255.0 --onboot=yes
network --hostname=FILL_IN_HERE

%packages
@^server-product-environment
@guest-agents --optional
@standard     --optional
cockpit-*
pcp-system-tools

@web-server
dhcp-server
tftp-server

autofs
nfs-utils
# iscsi-initiator-utils
# targetcli
%end

%addon com_redhat_kdump --disable --reserve-mb=auto
%end

firewall --enabled --ssh
selinux --disabled

%post --interpreter=/bin/sh
# Disable history
echo "unset HISTFILE" > /etc/profile.d/unset-histfile.sh
echo "history -c; rm -f ~/.bash_history ~/.lesshst ~/.viminfo" > /etc/bash.bash_logout

# Disable SELinux
# cp -afv /etc/selinux/config /etc/selinux/config.backup
# sed -E -e "s|^ *SELINUX *= *enforcing *$|SELINUX=disabled|gi" -i /etc/selinux/config

# Disable DNS lookup and GSSAPI (Kerberos)
cp -afv /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
sed -E -e "s|^ *GSSAPIAuthentication +yes *$|GSSAPIAuthentication no|gi" -i /etc/ssh/sshd_config
sed -E -e "s|^ *UseDNS +yes *$|UseDNS no|gi" -i /etc/ssh/sshd_config

# Disable password and root login
sed -E -e "s|^ *PasswordAuthentication +yes *$|PasswordAuthentication no|gi" -i /etc/ssh/sshd_config
sed -E -e "s|^ *PermitRootLogin +yes *$|PermitRootLogin no|gi" -i /etc/ssh/sshd_config

# Set cryptographic policies
update-crypto-policies --set FUTURE
%end
```

## References

[Kickstart File Format Reference](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/system_design_guide/kickstart-script-file-format-reference_system-design-guide)
[Kickstart Commands and Options Reference](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/system_design_guide/kickstart-commands-and-options-reference_system-design-guide)
