Skip to content

Template CentOS 7

Passo1: Minimal Instalation

Procedimento de instalação do CentOS 7, foi utilizado a ISO Minimal:

  1. Crie uma VM com o mínimo necessário e adicione a ISO e ligue a VM.
  1. Clique on “Install CentOS Linux 7”.

  2. Selecione o Idioma que deseja continuar o processo de instalação.

  3. Click em “Date & Time”.

  4. Selecione o Timezone que o melhor representa.

  5. Clique em “Installation Destionation”

  6. Clique para criar automaticamente .

  7. Defina a senha de ROOT

Espere a conclusão da Instalação e reinicie a Máquina.

Passo2: Minimal Instalation

Após a Máquina reiniciar, faça login com a senha definida pelo usuário root.

  1. É muito comum que o SELinux seja desabilitado. Vamos alterar em execução de “enforcing” para “permissive” com o comando setenforce e posteriormente vamos alterar no arquivo de configuração para na próxima vez que a máquina reinicie já fique com essa configuração realizada.

[root@localhost ~]#
[root@localhost ~]# setenforce 0
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@localhost ~]# getenforce
Permissive
02. Aproveite para instalar ferramentas necessárias para Troubleshooting e deixar o Sistema Up-To-Date ajudando a mitigar com correções e bugfixes.
[root@localhost ~]#
[root@localhost ~]# yum -y install vim wget psmisc htop epel-release
[root@localhost ~]# yum -y install selinux-policy yum-plugin-security
[root@localhost ~]# yum -y install tcpdump net-tools bind-utils telnet nmap
[root@localhost ~]# yum -y install open-vm-tools #(Caso esteja utilizando VMWARE como virtualizador)
[root@localhost ~]# systemctl restart vmtoolsd #(Caso esteja utilizando VMWARE como virtualizador)
[root@localhost ~]# systemctl enable vmtoolsd #(Caso esteja utilizando VMWARE como virtualizador)
[root@localhost ~]#
[root@localhost ~]# yum update -y
[root@localhost ~]#

PASSO 3: Zerando registros

Passos necessários para deixar o seu Sistema o mais labelless possível.

  1. Removendo configurações de udev rules, para que a placa de rede ao iniciar o sistema fique a primária padrão.

    [root@localhost etc]#
    [root@localhost etc]#  rm -f /etc/udev/rules.d/70-persistent-net.rules
    [root@localhost etc]#
    

  2. Habilitando a interface sem configuração prévia.

    [root@localhost etc]#
    [root@localhost etc]# vim /etc/sysconfig/network-scripts/ifcfg-ens160
    DEVICE=ens160
    ONBOOT=yes
    . . .
    [root@localhost ~]#
    

  3. Apagando as chaves criadas, (novas serão criadas durante o processo de boot)

    [root@localhost etc]#
    [root@localhost etc]# rm -rf /etc/ssh/ssh_host_*
    [root@localhost etc]#
    

  4. Limpando arquivos no filesystem e logs. Em seguida, desligando a máquina.

    [root@localhost ~]#
    [root@localhost ~]# yum clean -q all
    [root@localhost ~]#
    [root@localhost ~]# service rsyslog stop > /dev/null
    [root@localhost ~]# service auditd stop > /dev/null
    [root@localhost ~]#
    [root@localhost ~]# logrotate -f /etc/logrotate.conf
    [root@localhost ~]# rm -f /var/log/*-???????? /var/log/*.gz
    [root@localhost ~]# rm -rf /var/log/anaconda
    [root@localhost ~]# rm -f /var/log/dmesg.old
    [root@localhost ~]#
    [root@localhost ~]# cat /dev/null > /var/log/audit/audit.log
    [root@localhost ~]# cat /dev/null > /var/log/wtmp
    [root@localhost ~]# cat /dev/null > /var/log/lastlog
    [root@localhost ~]# cat /dev/null > /var/log/grubby
    [root@localhost ~]#
    [root@localhost ~]# rm -rf /tmp/*
    [root@localhost ~]# rm -rf /var/tmp/*
    [root@localhost ~]#
    [root@localhost ~]# rm -rf ~root/.ssh/
    [root@localhost ~]# rm -f ~root/anaconda-ks.cfg
    [root@localhost ~]#
    [root@localhost ~]# rm -f ~root/.bash_history
    [root@localhost ~]# rm -f /home/*/.bash_history
    [root@localhost ~]#
    [root@localhost ~]# touch /.unconfigured
    [root@localhost ~]#
    [root@localhost ~]# shutdown -h now
    [root@localhost ~]#
    

  5. Habilitando CPU/Memory Hot Plug

  6. Convertendo a máquina em template

Com isso finalizamos o template, para novas máquinas virtuais iniciem dentro do padrão, basta clicar no template com botão direito e clicar em “Criar nova VM a partir do Template”.