initial_config_centos8
Differences
This shows you the differences between two versions of the page.
| initial_config_centos8 [2025/07/26 17:09] – - Imported by DokuWiki Advanced Plugin wikiadm | initial_config_centos8 [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Configuração inicial - CentOS 8/ | ||
| - | ===== Configurando o sudo para o usuário suporte ===== | ||
| - | |||
| - | <file bash> | ||
| - | $ su - | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | # usermod -aG wheel suporte | ||
| - | # exit | ||
| - | sair | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo vim / | ||
| - | [...] | ||
| - | suporte | ||
| - | [...] | ||
| - | </ | ||
| - | |||
| - | Para que a configuração surta efeito, é necessário sair e acessar o servidor novamente. | ||
| - | |||
| - | <file bash> | ||
| - | $ exit | ||
| - | sair | ||
| - | Connection to 177.75.176.35 closed | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | ssh suporte@177.75.176.35 | ||
| - | suporte@177.75.176.35' | ||
| - | Last login: Fri May 20 08:54:40 2022 from 172.20.64.23 | ||
| - | </ | ||
| - | ===== Instalação de utilitário e bibliotecas ecenssiais para operar o sistema ===== | ||
| - | <file bash> | ||
| - | $ sudo dnf groupinstall " | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo dnf install dnf-utils vim-enhanced bash-completion wget bind-utils tcpdump traceroute | ||
| - | </ | ||
| - | FIXME Se o servidor estiver em um servidor ESXI é necessário instalar a biblioteca // | ||
| - | <file bash> | ||
| - | $ sudo dnf install open-vm-tools | ||
| - | </ | ||
| - | |||
| - | ===== Configuração de IPs ===== | ||
| - | <file bash> | ||
| - | $ sudo nmcli con mod ens160 ipv4.method manual ipv4.addresses 177.75.176.35/ | ||
| - | $ sudo nmcli con mod ens160 ipv6.method manual ipv6.addresses 2804: | ||
| - | $ sudo nmcli con mod ens160 ipv4.dns " | ||
| - | $ sudo nmcli con mod ens160 ipv6.dns " | ||
| - | $ sudo nmcli connection down ens160 ; sudo nmcli c up ens160 | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ ip -br address show | ||
| - | lo | ||
| - | ens160 | ||
| - | </ | ||
| - | |||
| - | ===== Configurando o hostname ===== | ||
| - | <file bash> | ||
| - | $ sudo hostnamectl set-hostname pa-mba-vm-01.juntotelecom.com.br | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ echo -e " | ||
| - | 177.75.176.35 | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ echo -e " | ||
| - | 2804: | ||
| - | </ | ||
| - | |||
| - | ===== Ajustando o relógio - NTP ===== | ||
| - | <file bash> | ||
| - | $ sudo timedatectl set-time ' | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ timedatectl list-timezones | grep Sao_Paulo | ||
| - | America/ | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo timedatectl set-timezone America/ | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo cp -p / | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo sed -i '/pool 2.pool.ntp.org iburst/ | ||
| - | $ sudo sed -i '/# | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo cat / | ||
| - | #pool 2.pool.ntp.org iburst | ||
| - | pool pool.ntp.br iburst | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo systemctl restart chronyd | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ chronyc sources -v | ||
| - | |||
| - | .-- Source mode ' | ||
| - | / .- Source state ' | ||
| - | | / ' | ||
| - | || .- xxxx [ yyyy ] +/- zzzz | ||
| - | || Reachability register (octal) -. | ||
| - | || Log2(Polling interval) --. | | yyyy = measured offset, | ||
| - | || \ | ||
| - | || | ||
| - | MS Name/IP address | ||
| - | =============================================================================== | ||
| - | ^+ a.st1.ntp.br | ||
| - | ^+ b.ntp.br | ||
| - | ^* gps.jd.ntp.br | ||
| - | ^+ b.st1.ntp.br | ||
| - | </ | ||
| - | ===== Desativando o acesso SSH para o usuário root ===== | ||
| - | <file bash> | ||
| - | $ sudo cp -p / | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | sudo sed -i '/ | ||
| - | sudo sed -i '/# | ||
| - | </ | ||
| - | |||
| - | **Ou** | ||
| - | |||
| - | <file bash> | ||
| - | sudo sed -i ' | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo cat / | ||
| - | # | ||
| - | PermitRootLogin no | ||
| - | </ | ||
| - | |||
| - | ===== Alterando a porta do SSH ===== | ||
| - | <file bash> | ||
| - | $ sudo sed -i '/# | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | [suporte@podman ~]$ sudo cat / | ||
| - | #Port 22 | ||
| - | Port 22022 | ||
| - | </ | ||
| - | |||
| - | ==== Conextos selinux ==== | ||
| - | <file bash> | ||
| - | $ sudo semanage port -a -t ssh_port_t -p tcp 22022 | ||
| - | sudo: semanage: comando não encontrado | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo dnf whatprovides semanage | ||
| - | Última verificação de data de vencimento de metadados: 2:57:15 atrás em sex 20 mai 2022 15:39:40 -03. | ||
| - | policycoreutils-python-utils-2.8-16.1.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-3.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-3.0.1.el8_1.1.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-9.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-14.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-16.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | |||
| - | policycoreutils-python-utils-2.9-19.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Nome de arquivo | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo dnf provides *bin/ | ||
| - | Última verificação de data de vencimento de metadados: 2:58:09 atrás em sex 20 mai 2022 15:39:40 -03. | ||
| - | policycoreutils-python-utils-2.8-16.1.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-3.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-3.0.1.el8_1.1.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-9.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-14.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-16.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | |||
| - | policycoreutils-python-utils-2.9-19.0.1.el8.noarch : SELinux policy core python utilities | ||
| - | Repo : ol8_baseos_latest | ||
| - | Resultado a partir de: | ||
| - | Outro : *bin/ | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo dnf install policycoreutils-python-utils | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo semanage port -a -t ssh_port_t -p tcp 22022 | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo systemctl restart sshd.service | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | [suporte@podman ~]$ ss -nltp | grep 22022 | ||
| - | LISTEN 0 128 0.0.0.0: | ||
| - | LISTEN 0 128 | ||
| - | </ | ||
| - | |||
| - | ===== Ajustes das regras de firewall ===== | ||
| - | ==== Listando todas as zonas ==== | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all-zones | ||
| - | block | ||
| - | target: %%REJECT%% | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | dmz | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | drop | ||
| - | target: DROP | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | external | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: yes | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | home | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client mdns samba-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | internal | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client mdns samba-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | nm-shared | ||
| - | target: ACCEPT | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: dhcp dns ssh | ||
| - | ports: | ||
| - | protocols: icmp ipv6-icmp | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | rule priority=" | ||
| - | |||
| - | public (active) | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: ens160 | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | trusted | ||
| - | target: ACCEPT | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | |||
| - | work | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | ==== Listando as zonas com regras padrão ==== | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all --zone=home | ||
| - | home | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client mdns samba-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all --zone=internal | ||
| - | internal | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client mdns samba-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all --zone=nm-shared | ||
| - | nm-shared | ||
| - | target: ACCEPT | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: dhcp dns ssh | ||
| - | ports: | ||
| - | protocols: icmp ipv6-icmp | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | rule priority=" | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all --zone=public | ||
| - | public (active) | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: ens160 | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all --zone=work | ||
| - | work | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | ==== Ajustando as regras do SSH da zona ativa - principal/ | ||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --get-default-zone | ||
| - | public | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all | ||
| - | public (active) | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: ens160 | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client ssh | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | </ | ||
| - | |||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --permanent --zone=public --remove-service=ssh | ||
| - | success | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
| - | $ sudo firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
| - | $ sudo firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
| - | $ sudo firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
| - | $ sudo firewall-cmd --permanent --add-rich-rule 'rule family=" | ||
| - | [suporte@podman ~]$ sudo firewall-cmd --reload | ||
| - | </ | ||
| - | |||
| - | <file bash> | ||
| - | $ sudo firewall-cmd --list-all | ||
| - | public (active) | ||
| - | target: default | ||
| - | icmp-block-inversion: | ||
| - | interfaces: ens160 | ||
| - | sources: | ||
| - | services: cockpit dhcpv6-client | ||
| - | ports: | ||
| - | protocols: | ||
| - | forward: no | ||
| - | masquerade: no | ||
| - | forward-ports: | ||
| - | source-ports: | ||
| - | icmp-blocks: | ||
| - | rich rules: | ||
| - | rule family=" | ||
| - | rule family=" | ||
| - | rule family=" | ||
| - | rule family=" | ||
| - | rule family=" | ||
| - | </ | ||
| - | ===== Configuração do vim ===== | ||
| - | [[vimrc_v2|vimrc]] | ||
| - | |||
| - | ===== Configuração do bash ===== | ||
| - | <file bash bashrc> | ||
| - | #vim ~/.bashrc | ||
| - | # .bashrc | ||
| - | # Cores | ||
| - | Preto=' | ||
| - | Vermelho=' | ||
| - | Verde=' | ||
| - | Amarelo=' | ||
| - | Azul=' | ||
| - | Roxo=' | ||
| - | Ciano=' | ||
| - | Branco=' | ||
| - | Cinza=' | ||
| - | |||
| - | PS1=" | ||
| - | |||
| - | HISTTIMEFORMAT=' | ||
| - | HISTCONTROL=ignoreboth | ||
| - | HISTSIZE=1000 | ||
| - | HISTFILESIZE=2000 | ||
| - | shopt -s checkwinsize | ||
| - | |||
| - | EDITOR=' | ||
| - | |||
| - | alias rm='rm -i' | ||
| - | alias cp='cp -i' | ||
| - | alias mv='mv -i' | ||
| - | alias echo='/ | ||
| - | alias egrep=' | ||
| - | alias fgrep=' | ||
| - | alias grep=' | ||
| - | alias l.='ls -d .* --color=auto' | ||
| - | alias ll='ls -l --color=auto' | ||
| - | alias ls='ls --color=auto' | ||
| - | alias vi=' | ||
| - | alias ping=' | ||
| - | [...] | ||
| - | </ | ||
initial_config_centos8.1753560543.txt.gz · Last modified: by wikiadm
