dselect
, remove all unneeded but selected packages before doing [I]nstall. Keep the bare minimum of packages for the system.
lilo
$ ps aux $ netstat -pn -l -A inet # /usr/sbin/lsof -i | grep LISTENYou will need to install lsof-2.2 for the third command to work (run it as root). You should be aware that
lsof
can translate the word LISTEN to your locale settings.
lsof
and dpkg
, does just that:
#!/bin/sh # FIXME: 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 Section 3.5.1, “Disabling daemon services”).
/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
), check that the files /etc/hosts.allow
and /etc/hosts.deny
are configured according to your service policy.
# 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 Section B.7, “Chroot environment for SSH”.