NUT installation
Jan 14, 08 by Juan Lebrijo about blog, SAI
NUT (Network UPS Tool) is a group of tools to administer Uninterruptible Power Systems which ensure the continuous suply for our equipment. With this article we install and configure the tool in a Debian etch. I will configure an UPS BELKIN SurgeMaster of 650 VA. But you can see the compatibility with operating system and NUT, of your UPS, in the URL: http://www.networkupstools.org/compat/stable.html. I am based en my reference table: Origin http://www.networkupstools.org/ Repository apt Package Nut 2.0.4 Documentation (spanish) http://www.servitux.org/view.php/page/sai Documentation (english) http://www.networkupstools.org/doc/2.0.1/ Install the package:
elite:~# apt-get install nut nut-snmp nut-usb
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Se instalarán los siguientes paquetes extras:
  libsensors3 libsnmp-base libsnmp9 libsysfs2
Paquetes sugeridos:
  lm-sensors nut-cgi nut-dev
Se instalarán los siguientes paquetes NUEVOS:
  libsensors3 libsnmp-base libsnmp9 libsysfs2 nut nut-snmp nut-usb
0 actualizados, 7 se instalarán, 0 para eliminar y 1 no actualizados.
Se necesita descargar 3122kB/4432kB de archivos.
Se utilizarán 9847kB de espacio de disco adicional después de desempaquetar.
SNMP tools to centralize the network information of the systems, and usb tool to connect the hardware through USB ports. In the file /etc/default/nut, we write the variables to initialize the servers:
# start upsd
START_UPSD=yes

# start upsmon
START_UPSMON=yes
Add the nut user to the group dialout which controls the serial interfaces:
elite:~#  adduser nut dialout
Create the configuration files:
cp /usr/share/doc/nut/examples/ups.conf /etc/nut/
cp /usr/share/doc/nut/examples/upsd.users /etc/nut/
cp /usr/share/doc/nut/examples/upsd.conf /etc/nut/
cp /usr/share/doc/nut/examples/upsmon.conf.gz /etc/nut/
gzip -d /etc/nut/upsmon.conf.gz
In ups.conf:
[misai]
        driver = megatec
          port = /dev/ttyS0
The upsd.conf leave equal, it is the server daemon configuration. Theupsd.users is:
[admin]
        password = upssai
        allowfrom = localhost
        actions = SET
        instcmds = ALL

[control]
        password = upssai
        allowfrom = localhost
        upsmon master

[clientes]
        password = upssai
        allowfrom = negro
        upsmon slave
Appears "negro" as SAI client, it is a desktop PC which is connected to the SAI. Really I do not want "negro" monitorice (it is a windows system), but I want previous the server shutdown, the server sends it a shutdown order. In upsmon.conf add in order:
MONITOR misai@localhost 1 control upssai master

SHUTDOWNCMD "/etc/nut/apagado_sistema.sh"

NOTIFYCMD /etc/nut/mensaje-ups.sh

NOTIFYMSG ONLINE "UPS %s en estado normal"
NOTIFYMSG ONBATT "Alguien ha quitado el cable del SAI %s"
NOTIFYMSG LOWBATT "Bateria demasiado baja"
NOTIFYMSG FSD "Ha llegado el momento de apagar el SAI"
NOTIFYMSG COMMOK "Fiiiuuu, ya puedo volver a hablar con el SAI"
NOTIFYMSG COMMBAD "Otiiaa, que el SAI no me habla"
NOTIFYMSG SHUTDOWN "Apagando!"
NOTIFYMSG REPLBATT "Macho, ves cambiando la bateria"

NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+EXEC
NOTIFYFLAG COMMBAD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
NOTIFYFLAG REPLBATT SYSLOG+EXEC
Create the message batch to notify mensaje-ups.sh:
#!/bin/sh

echo "
ATENCION
----------------------

MENSAJE DEL SAI: $NOTIFYTYPE" | mail -s "MENSAJE DEL SAI" admin@lebrijo.com
Create the script with shutdown orders apagado_sistema.sh:
#!/bin/sh

# Apagamos el PC de escritorio (si estuviera encendido)
ssh -i /etc/nut/rsa_ups ups@negro.lebrijo.com "shutdown -s –f"
# Apagamos el servidor elite
/sbin/shutdown -h +0
Change the file permissions to execute them:
chmod 744 /etc/nut/*.sh
In a future entry we will see how to configure a sshd server in Windows to receive the las order.
Control de acceso en Apache con LDAP
Jan 07, 08 by Juan Lebrijo about blog, LDAP, security, Web
Nuestro objetivo es que cuando se acceda a la carpeta http://www.midominio.com/privado/, se haga control de acceso, es decir, se solicite usuario/contraseña, que valide contra nuestro servidor de directorio. Como siempre partimos de nuestro servidor Debian etch, con Apache/2.2.3 instalado. Nos basamos en la documentación oficial, necesitamos habilitados los módulos:
~# cd /etc/apache2/mods-enabled/
~# ln -s ../mods-available/auth_basic.load auth_basic.load
~# ln -s ../mods-available/authnz_ldap.load authnz_ldap.load
~# ln -s ../mods-available/ldap.load ldap.load
~# /etc/init.d/apache restart
Luego en nuestro VirtualHost ponemos en la directiva Location:
<Location "/privado/">
                AuthBasicProvider ldap
                AuthType Basic
                AuthzLDAPAuthoritative off
                AuthName "Archivos privados"
                AuthLDAPURL "ldap://ldap.midominio.com:389/dc=midominio,dc=com"
                require valid-user
        </Location>
Este es un Control de Acceso basado en LDAP muy básico. Podríamos aplicar la directiva "require group administradores" y solo se permitiría el acceso al grupo administradores. O también se puede hacer desde .htaccess, si no tienes permiso para editar la configuración de Apache En fin, para más información lo mejor es la fuente original ó googlear un poco.
Access control in Apache with LDAP
Jan 07, 08 by Juan Lebrijo about blog, LDAP, security, Web
Our target is that when is acceded the directory http://www.midominio.com/privado/, our server makes access control, then it ask for an user/password, and validate trough our directory server. As usually, we install over Debian etch server, with Apache/2.2.3. We are based on oficial documentation, we need availabel the following modules:
~# cd /etc/apache2/mods-enabled/
~# ln -s ../mods-available/auth_basic.load auth_basic.load
~# ln -s ../mods-available/authnz_ldap.load authnz_ldap.load
~# ln -s ../mods-available/ldap.load ldap.load
~# /etc/init.d/apache restart
After thet we will write the Location directive in our VirtualHost:
<Location "/privado/">
                AuthBasicProvider ldap
                AuthType Basic
                AuthzLDAPAuthoritative off
                AuthName "Archivos privados"
                AuthLDAPURL "ldap://ldap.midominio.com:389/dc=midominio,dc=com"
                require valid-user
        </Location>
This an very basic access control LDAP based. We could aply the "require group administrators" directive and we only allow access for the Administrators LDAP group. Or we could make this control in .htaccess file, if you do not have permissions to edit Apache configuration. At last, better way in the original source or googling a bit.