authbind

The authbind is used to running network services as a non root user

Using authbind

The authbind package is designed to allow users to bind servers upon a low-numbered port. The package may be easily installed upon Debian systems by executing:

root@lappy:# apt-get install authbind .. ..

Once installed the software is configured via files located beneath /etc/authbind. There are three subdirectories:

    • /etc/authbind/byport

    • /etc/authbind/byuid

    • /etc/authbind/byaddr

The manpage to the authbind program explains how these subdirectories are used. But as a simple example we can allow the user skx to bind to port 80 by running the following commands:

root@lappy:~# touch /etc/authbind/byport/80 root@lappy:~# chown skx:skx /etc/authbind/byport/80 root@lappy:~# chmod 755 /etc/authbind/byport/80

Here we have created a file with the name 80 (which is used to specify that the user may bind to port 80). This file is executable to the user skx - this is sufficient for the user to bind to port 80 - if they prefix their command with authbind.

For example the skx user could run something like the following:

skx@lappy:~$ authbind nc -l -p 80 -e "/usr/bin/uptime"

(This listens for incoming connections on port 80 and sends the output of the uptime command to connecting clients. It is the simplest test of binding a socket

Running network service as non-root user