dselect
y remueva lo que no es necesario, si no selecciono paquetes antesv de ser (I)instalados. Deje la menor cantidad de programas necesarios en el servidor.
$ ps -aux $ netstat -pn -l -A inet # /usr/sbin/lsof -i | grep LISTENNecesitará instalar lsof-2.2 para que el tercer comando funcione (corralo como root). Debería ser consiente que lsof puede transladar la palabra LISTEN a su configuraciones de los locales.
lsof
and dpkg
, does just that:
#!/bin/sh # ARREGLAME: this is quick and dirty; replace with a more robust script snippet for i in `sudo lsof -i | grep LISTEN | cut -d " " -f 1 |sort -u` ; do pack=`dpkg -S $i |grep bin |cut -f 1 -d : | uniq` echo "Service $i is installed by $pack"; init=`dpkg -L $pack |grep init.d/ ` if [ ! -z "$init" ]; then echo "and is run by $init" fi done
dpkg --purge
), or disable the service from starting automatically at boot time using update-rc.d
(see Sección 3.5.1, “Deshabilitar servicios”).
/etc/inetd.conf
using:
$ grep -v "^#" /etc/inetd.conf | sort -uThen disable those services that are not needed by commenting out the line that includes them in
/etc/inetd.conf
, removing the package, or using update-inetd
.
/usr/sbin/tcpd
) revise que los /etc/hosts.allow
y /etc/hosts.deny
estén configurados acorde a su política de servicios.
# init 1 (....) # init 2
# for i in `/usr/sbin/lsof -i |grep LISTEN |cut -d " " -f 1 |sort -u`; \ > do user=`ps ef |grep $i |grep -v grep |cut -f 1 -d " "` ; \ > echo "Service $i is running as user $user"; doneConsider changing these services to a specific user/group and maybe
chroot
'ing them for increased security. You can do this by changing the /etc/init.d
scripts which start the service. Most services in Debian use start-stop-daemon
, which has options (--change-uid
and --chroot
) for accomplishing this. A word of warning regarding the chroot
'ing of services: you may need to put all the files installed by the package (use dpkg -L) providing the service, as well as any packages it depends on, in the chroot
'ed environment. Information about setting up a chroot
environment for the ssh
program can be found in Sección B.7, “Chroot environment for SSH”.