Product SiteDocumentation Site

3.5. Ejecute el mínimo número de servicios requeridos

Los servicios son programas como los servidores de ftp y los servidores de web. Puesto que éstos tienen que estar escuchando las conexiones entrantes para detectar solicitudes de servicio, ordenadores externos pueden conectarse a los suyos. Los servicios son algunas veces vulnerables (p. ejem. pueden resultar comprometidos por un ataque determinado) y presentan por tanto un riesgo para la seguridad.
No debería instalar servicios que su máquina no necesite. Cada servicio instalado podría introducir nuevos, quizás no obvios (o conocidos), agujeros de seguridad en su ordenador.
As you may already know, when you install a given service the default behavior is to activate it. In a default Debian installation, with no services installed, the number of running services is quite low and the number of network-oriented services is even lower. In a default Debian 3.1 standard installation you will end up with OpenSSH, Exim (depending on how you configured it) and the RPC portmapper available as network services[4]. If you did not go through a standard installation but selected an expert installation you can end up with no active network services. The RPC portmapper is installed by default because it is needed for many services, for example NFS, to run on a given system. However, it can be easily removed, see Sección 5.13, “Securing RPC services” for more information on how to secure or disable RPC services.
Cuando instala un nuevo servicio relacionado con la red (demonio) en su sistema Debian GNU/Linux, puede habilitarlo de dos formas: por medio del superdemonio inetd (esto es, añadiendo una línea a /etc/inetd.conf) o por medio de un programa autónomo que enlace con sus interfaces de red. Los programas autónomos se controlan a través de los archivos de /etc/init.d, a los que se llama durante el arranque por medio de los mecanismos de SysV (o un alternativo) utilizando enlaces simbólicos en /etc/rc?.d/* (para más información sobre cómo se hace esto, lea /usr/share/doc/sysvinit/README.runlevels.gz).
If you want to keep some services but use them rarely, use the update-* commands, e.g. update-inetd and update-rc.d to remove them from the startup process. For more information on how to disable network services read Sección 3.5.1, “Deshabilitar servicios”. If you want to change the default behaviour of starting up services on installation of their associated packages[5] use policy-rc.d, please read /usr/share/doc/sysv-rc/README.policy-rc.d.gz for more information.
invoke-rc.d support is mandatory in Debian, which means that for Debian 4.0 etch and later releases you can write a policy-rc.d file that forbids starting new daemons before you configure them. Although no such scripts are packaged yet, they are quite simple to write. See policyrcd-script-zg2.

3.5.1. Deshabilitar servicios

Disabling a daemon service is quite simple. You either remove the package providing the program for that service or you remove or rename the startup links under /etc/rc${runlevel}.d/. If you rename them make sure they do not begin with 'S' so that they don't get started by /etc/init.d/rc. Do not remove all the available links or the package management system will regenerate them on package upgrades, make sure you leave at least one link (typically a 'K', i.e. kill, link). For more information read http://iwawocd.cewmufwd.tk/doc/manuals/reference/ch-system.en.html#s-custombootscripts section of the Debian Reference (Chapter 2 - Debian fundamentals).
You can remove these links manually or using update-rc.d (see update-rc.d(8)). For example, you can disable a service from executing in the multi-user runlevels by doing:
  # update-rc.d name stop XX 2 3 4 5 .
Donde XX es un número que determinará cuándo se ejecutará la acción de parada de ese servicio. Por favor observe que, si no utiliza file-rc, update-rc.d -f service remove no funcionará correctamente, puesto que se eliminarán todos los enlaces, y éstos se regenerarán con la reinstalación o actualización del paquete (que probablemente no sea lo que desea). Si piensa que esto no es intuitivo, probablemente tenga razón (vea http://bugs.debian.org/67095). De la página del manual:
  Si alguno de los archivos /etc/rcrunlevel.d/[SK]??nombre ya existe, entonces
  update-rc.d no hará nada. Esto es así para que el administrador del sistema
  pueda reorganizar los enlaces, y siempre que deje al menos un enlace sin
  eliminar, su configuración no se sobreescribirá.
Si utiliza file-rc toda la información relativa al arranque de servicios se manipula por un archivo de configuración común y se mantiene incluso si los paquetes se eliminan del sistema.
You can use the TUI (Text User Interface) provided by sysv-rc-conf to do all these changes easily (sysv-rc-conf works both for file-rc and normal System V runlevels). You will also find similar GUIs for desktop systems. You can also use the command line interface of sysv-rc-conf:
  # sysv-rc-conf foobar off
The advantage of using this utility is that the rc.d links are returned to the status they had before the 'off' call if you re-enable the service with:
  # sysv-rc-conf foobar on
Other (less recommended) methods of disabling services are:
  • Removing the /etc/init.d/service_name script and removing the startup links using:
      # update-rc.d name remove
  • Move the script file (/etc/init.d/service_name) to another name (for example /etc/init.d/OFF.service_name). This will leave dangling symlinks under /etc/rc${runlevel}.d/ and will generate error messages when booting up the system.
  • Remove the execute permission from the /etc/init.d/service_name file. That will also generate error messages when booting.
  • Edit the /etc/init.d/service_name script to have it stop immediately once it is executed (by adding an exit 0 line at the beginning or commenting out the start-stop-daemon part in it). If you do this, you will not be able to use the script to startup the service manually later on.
Nevertheless, the files under /etc/init.d are configuration files and should not get overwritten due to package upgrades if you have made local changes to them.
A diferencia de otros sistemas operativos (UNIX), los servicios en Debian no pueden deshabilitarse mediante la modificación de los archivos en /etc/default/service_name.
ARRÉGLEME: Añada más información sobre la manipulación de demonios utilizando file-rc

3.5.2. Disabling inetd or its services

You should check if you really need the inetd daemon nowadays. Inetd was always a way to compensate for kernel deficiencies, but those have been taken care of in modern Linux kernels. Denial of Service possibilities exist against inetd (which can increase the machine's load tremendously), and many people always preferred using stand-alone daemons instead of calling services via inetd. If you still want to run some kind of inetd service, then at least switch to a more configurable Inet daemon like xinetd, rlinetd or openbsd-inetd.
You should stop all unneeded Inetd services on your system, like echo, chargen, discard, daytime, time, talk, ntalk and r-services (rsh, rlogin and rcp) which are considered HIGHLY insecure (use ssh instead).
Puede deshabilitar servicios editando directamente /etc/inetd.conf, pero Debian proporciona una mejor alternativa: update-inetd (que comenta los servicios en una forma que hace fácil volver a activarlos). Podría detener el demonio de telnet mediante la ejecución de estos comandos para cambiar el archivo de configuración y volver a arrancar el demonio (en este caso el servicio de telnet está deshabilitado):
  /usr/sbin/update-inetd --disable telnet
Si quiere tener servicios escuchando, pero no quiere tenerlos escuchando en todas las direcciones IP de su ordenador principal, podría querer utilizar una característica no documentada de inetd (remplazar el nombre del servicio por la sintaxis servicio@ip) o utilizar un demonio alternativo como xinetd.


[4] The footprint in Debian 3.0 and earlier releases wasn't as tight, since some inetd services were enabled by default. Also standard installations of Debian 2.2 installed the NFS server as well as the telnet server.
[5] This is desirable if you are setting up a development chroot, for example.