110.2 Configurar la seguridad del host - Comandos clave

Servicios (systemctl)

ComandoDescripcion
systemctl list-units --type=service --state=runningListar servicios activos
systemctl stop servicioDetener servicio
systemctl disable servicioNo iniciar al arrancar
systemctl mask servicioBloquear completamente
systemctl unmask servicioDesbloquear
systemctl is-enabled servicioVerificar si esta habilitado

Shadow passwords

ArchivoPermisosContenido
/etc/passwd644 (todos leen)Info de usuario (x en campo password)
/etc/shadow640 o 000 (solo root)Hash de contrasenas

Formato de /etc/shadow

usuario:$tipo$sal$hash:lastchg:min:max:warn:inactive:expire:

Tipos de hash

PrefijoAlgoritmo
$6$SHA-512
$5$SHA-256
$1$MD5
! / !!Cuenta bloqueada
*Sin login

TCP Wrappers

Orden de evaluacion

  1. /etc/hosts.allow (si match -> PERMITIR)
  2. /etc/hosts.deny (si match -> DENEGAR)
  3. Si no hay match -> PERMITIR

Formato

servicio: host [: accion]

Politica restrictiva (recomendada)

/etc/hosts.deny:

ALL: ALL

/etc/hosts.allow:

sshd: 192.168.1.0/24
ALL: localhost

Comodines

ComodinSignificado
ALLTodos
LOCALHosts locales
EXCEPTExclusion

inetd vs xinetd

inetdxinetd
/etc/inetd.conf/etc/xinetd.conf + /etc/xinetd.d/
Comentar con #disable = yes
Una linea por servicioUn archivo por servicio

/etc/nologin

AccionComando
Impedir loginsecho "Mantenimiento" > /etc/nologin
Permitir loginsrm /etc/nologin

Archivos clave

ArchivoDescripcion
/etc/passwdInfo de usuarios (legible por todos)
/etc/shadowContrasenas encriptadas (solo root)
/etc/hosts.allowReglas de permiso (TCP Wrappers)
/etc/hosts.denyReglas de denegacion (TCP Wrappers)
/etc/xinetd.confConfig global de xinetd
/etc/xinetd.d/Config por servicio de xinetd
/etc/inetd.confConfig de inetd
/etc/nologinSi existe, impide login de usuarios normales
/etc/securettyTerminales donde root puede hacer login