<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="https://uname.pingveno.net/blog/index.php/feed/rss2/xslt" ?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title># uname -a - Mot-clé - debian</title>
    <link>https://uname.pingveno.net/blog/index.php/</link>
    <atom:link href="https://uname.pingveno.net/blog/index.php/feed/tag/debian/rss2" rel="self" type="application/rss+xml" />
    <description>Le blog de uname.pingveno.net</description>
    <language>fr</language>
    <pubDate>Wed, 01 Apr 2026 16:19:15 +0200</pubDate>
    <copyright>Mathieu Pellegrin</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>Dotclear</generator>
          <item>
        <title>Redémarrer une machine lorsqu'un programme l'étouffe inopinément (Debian 10)</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2020/10/15/Red%C3%A9marrer-une-machine-lorsqu-un-programme-l-%C3%A9touffe-inopin%C3%A9ment-%28Debian-10%29</link>
        <guid isPermaLink="false">urn:md5:2df2a5ec71b76a25b469cd103931185c</guid>
        <pubDate>Wed, 14 Oct 2020 12:40:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>limits</category>
                  <category>linux</category>
                  <category>memory</category>
                  <category>overflow</category>
                  <category>reboot</category>
                  <category>watchdog</category>
                <description>          &lt;p&gt;Admettons que vous ayez une machine avec un programme bugué. Typiquement, un logiciel métier avec une fuite de mémoire, qui va pour une raison inconnue saturer la mémoire vive et provoquer son propre crash ou le crash des autres services sur la machine.&lt;/p&gt;

&lt;p&gt;Vous pourriez lui mettre une limite de mémoire via &lt;a href=&quot;https://linux.die.net/man/5/limits.conf&quot; hreflang=&quot;en&quot;&gt;/etc/security/limits.conf&lt;/a&gt; mais ça ne fera que planter le programme (segmentation fault) pour protéger les autres, et dans le cas d'un logiciel métier cela veut dire prendre ensuite d'autres actions, manuelles ou automatiques, via un système de monitoring approprié.&lt;/p&gt;

&lt;p&gt;C'est vrai, le monitoring est la bonne solution quand on suit un logiciel aussi critique qu'un logiciel métier, mais dans le cas d'un logiciel qui doit &quot;juste tourner&quot;, d'une équipe de maintenance réduite ou n'ayant pas la possibilité d'astreintes, une solution simple pour s'assurer que la machine tourne même en cas d'incident, c'est de redémarrer la machine lors d'un incident. Pour cela, on peut utiliser le programme &lt;strong&gt;watchdog&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Cela doit être fait avec motivations et circonspection, une analyse &quot;post-mortem&quot; doit suivre chaque reboot, dans le cas d'une tentative d'élévation de privilèges par Buffer Overflow, rien ne dit que l'attaque n'a pas réussie même si le système a redémarré.&lt;/p&gt;

&lt;h3&gt;Watchdog : Configuration&lt;/h3&gt;

&lt;p&gt;Watchdog s'installe via les paquets :&lt;/p&gt;

&lt;pre&gt;
apt install watchdog&lt;/pre&gt;

&lt;p&gt;Il y a ensuite deux choses à configurer : les règles pour déclencher le reboot, et le mode de chargement du programme (&quot;no actions&quot; ou actif).&lt;/p&gt;

&lt;p&gt;Dans mon cas, je voulais redémarrer si le serveur avait moins de 20% de RAM disponible, ce serveur tourne en permanence à 50% de consommation de RAM et n'est jamais sensé dépasser, ou alors c'est signe d'un problème, d'où le reboot à déclencher.&lt;/p&gt;

&lt;p&gt;La configuration de watchdog se trouve dans &lt;strong&gt;/etc/watchdog.conf&lt;/strong&gt; et fournit deux valeurs à régler : &lt;strong&gt;min-memory&lt;/strong&gt; et &lt;strong&gt;allocatable-memory&lt;/strong&gt; . Attention, ces valeurs sont à renseigner en &lt;strong&gt;taille de page RAM&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Pour identifier la taille des pages sur le système, utilisez la commande :&lt;/p&gt;

&lt;pre&gt;
getconf PAGESIZE&lt;/pre&gt;

&lt;p&gt;Ensuite, un simple calcul permet d'identifier la valeur à mettre dans min-memory et allocatable-memory. Par exemple, pour un PAGESIZE de 4096 (4 kB), 2 GB (2048 MB) de RAM et 20% de ce total :&lt;/p&gt;

&lt;pre&gt;
( 20 % * 2048 * 1000 ) / 4096&lt;/pre&gt;

&lt;p&gt;Une fois &lt;strong&gt;min-memory&lt;/strong&gt; et &lt;strong&gt;allocatable-memory&lt;/strong&gt; configurés, il convient de tester le trigger avant de le démarrer;&lt;/p&gt;

&lt;p&gt;Les options de lancement se trouvent dans &lt;strong&gt;/etc/default/watchdog&lt;/strong&gt; . Modifier &lt;strong&gt;watchdog_options&lt;/strong&gt; pour y renseigner :&lt;/p&gt;

&lt;pre&gt;
watchdog_options=&quot;-v --no-action&quot;&lt;/pre&gt;

&lt;p&gt;Désactivez Watchdog du démarrage automatique, puis démarrez-le :&lt;/p&gt;

&lt;pre&gt;
systemctl disable watchdog
service watchdog start&lt;/pre&gt;

&lt;p&gt;Vous en verrez la trace dans les logs via &lt;strong&gt;service watchdog status&lt;/strong&gt; ou &lt;strong&gt;journalctl -f&lt;/strong&gt; .&lt;/p&gt;

&lt;h3&gt;Watchdog : Activation&lt;/h3&gt;

&lt;p&gt;Si les essais sont concluants, retournez dans &lt;strong&gt;/etc/default/watchdog&lt;/strong&gt; pour activer le module noyau. Cela évitera que Watchdog se fasse tuer par un processus quelconque (oom-killer par exemple) :&lt;/p&gt;

&lt;pre&gt;
watchdog_module=&quot;softdog&quot;&lt;/pre&gt;

&lt;p&gt;Si vous ne voulez laisser aucune chance pour éviter le reboot (par exemple si oom-killer a réussi à baisser la consommation de ram sous le seuil acceptable et que le reboot n'est plus nécessaire), rajoutez &lt;strong&gt;nowayout&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;watchdog_module=&quot;softdog nowayout&quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Attention, une fois chargé en &lt;strong&gt;nowayout&lt;/strong&gt;, le module noyau restera actif même si watchdog est stoppé (légitimement ou non), le seul moyen de le retirer est de retirer softdog des modules noyau (via &lt;strong&gt;rmmod&lt;/strong&gt;), ou de rebooter.&lt;/p&gt;

&lt;p&gt;Activez ensuite watchdog :&lt;/p&gt;

&lt;pre&gt;
systemctl enable watchdog
service watchdog start&lt;/pre&gt;

&lt;p&gt;watchdog doit être visible dans les modules noyau chargés :&lt;/p&gt;

&lt;pre&gt;
lsmod | grep softdog&lt;/pre&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.cyberciti.biz/faq/linux-check-the-size-of-pagesize/&quot; hreflang=&quot;en&quot;&gt;Page size check&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.supertechcrew.com/watchdog-keeping-system-always-running/&quot; hreflang=&quot;en&quot;&gt;Watchdog configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Maman, j'ai patché Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2020/03/19/Maman-j-ai-patch%C3%A9-Debian</link>
        <guid isPermaLink="false">urn:md5:71a75a5565e36a22a1a7aac2045ae2d7</guid>
        <pubDate>Thu, 19 Mar 2020 15:33:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>compile</category>
                  <category>debian</category>
                  <category>debuild</category>
                  <category>package</category>
                  <category>patch</category>
                <description>          &lt;p&gt;Un billet en forme de note à moi-même sur ce qu'il faut faire pour correctement :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Récupérer un package depuis upstream&lt;/li&gt;
	&lt;li&gt;Appliquer un ou plusieurs patches&lt;/li&gt;
	&lt;li&gt;Le signer et le re-déployer en production&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Préparer l'environnement&lt;/h3&gt;

&lt;p&gt;Pour compiler et signer un paquet simplement il vous faut :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Un utilisateur (non root)&lt;/li&gt;
	&lt;li&gt;Une clé GPG&lt;/li&gt;
	&lt;li&gt;Les build-essentials et les devscripts (parce qu'on est feignasse)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Créez un utilisateur non-root et loguez-vous avec. N'utilisez pas &quot;su&quot; à partir de root, parce que sinon GPG ne pourra pas vous demander la phrase de passe (des histoires de droits sur les TTY).&lt;/p&gt;

&lt;p&gt;Créez une clé GPG, et paramétrez-la :&lt;/p&gt;

&lt;pre&gt;
gpg --full-generate-key&lt;/pre&gt;

&lt;p&gt;Récupérez l'identifiant de clé à la fin de la procédure, ou avec &lt;strong&gt;gpg&amp;nbsp;--list-keys&lt;/strong&gt; si vous l'avez loupé.&lt;/p&gt;

&lt;p&gt;Modifiez ou créez le fichier &lt;strong&gt;~/.devscripts&lt;/strong&gt; et ajoutez :&lt;/p&gt;

&lt;pre&gt;
DEBUILD_SET_ENVVAR_DEBSIGN_KEYID=xxxxxxxx
&lt;/pre&gt;

&lt;p&gt;Avec le xxxxxx qui correspond à votre identifiant de clé.&lt;/p&gt;

&lt;h3&gt;Récupérer le paquet et les dépendances de compilation&lt;/h3&gt;

&lt;p&gt;Le plus simple c'est quand le paquet existe déjà et qu'il faut simplement patcher. S'il n'existe aucun paquet, il faut créer un nouveau paquet, éventuellement debianizer la configuration, et c'est une autre paire de manches (et c'est pas le sujet ici).&lt;/p&gt;

&lt;p&gt;Pour récupérer le paquet upstream :&lt;/p&gt;

&lt;pre&gt;
apt-get source nomdupaquet&lt;/pre&gt;

&lt;p&gt;Si le paquet est introuvable, ajoutez les dépôts src à votre sources.list :&lt;/p&gt;

&lt;pre&gt;
&lt;strong&gt;deb-src&lt;/strong&gt; http://deb.debian.org/debian/ buster main contrib
&lt;strong&gt;deb-src&lt;/strong&gt; http://security.debian.org/debian-security buster/updates main contrib
&lt;strong&gt;deb-src&lt;/strong&gt; http://deb.debian.org/debian/ buster-updates main contrib&lt;/pre&gt;

&lt;p&gt;Il faut ensuite récupérer les paquets nécessaires à la compilation. Coup de bol, si vous avez pu avoir le paquet source à l'étape précédente, c'est facile :&lt;/p&gt;

&lt;pre&gt;
apt-get build-dep nomdupaquet&lt;/pre&gt;

&lt;h3&gt;Patcher le paquet&lt;/h3&gt;

&lt;p&gt;Le format dpatch est obsolète, en principe votre package utilise quilt comme tout paquet récent. Il suffit de télécharger le patch depuis git et le placer dans le dossier &lt;strong&gt;debian/patches&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Ensuite, ajoutez le nom du fichier que vous avez ajouté au fichier &lt;strong&gt;debian/patches/series&lt;/strong&gt; . Attention, l'ordre dans series est important.&lt;/p&gt;

&lt;h3&gt;Déclarer les changements&lt;/h3&gt;

&lt;p&gt;Ce n'est pas nécessaire la première fois, mais si vous re-compilez un paquet, il faut ajouter un commentaire dans le Changelog. Le plus simple : utilisez la commande &lt;strong&gt;dch -i&amp;nbsp; &lt;/strong&gt;et modifiez la ligne de changelog, en changeant bien la version du paquet pour qu'elle soit consécutive à la précédente.&lt;/p&gt;

&lt;h3&gt;Compiler le paquet&lt;/h3&gt;

&lt;p&gt;Rendez-vous dans le dossier du paquet, et lancez la commande &lt;strong&gt;debuild&lt;/strong&gt; . C'est tout. Rentrez votre phrase de passe pour la clé à la fin de la procédure.&lt;/p&gt;

&lt;h3&gt;Déployer en production&lt;/h3&gt;

&lt;p&gt;Pour déployer un paquet, deux solutions :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Envoyer le paquet puis l'installer avec &lt;strong&gt;dpkg -i lefichier.deb&lt;/strong&gt; ou un outil d'orchestration&lt;/li&gt;
	&lt;li&gt;Installer un DPA (Debian Private Repository) et l'ajouter au sources.list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;L'installation du serveur DPA fera l'objet d'un autre billet (un jour).&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://help.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key&quot;&gt;Create GPG KEY&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://wiki.debian.org/debian/patches&quot;&gt;Patch a Debian package&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.debian.org/doc/manuals/maint-guide/build.en.html&quot;&gt;Build a Debian package&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Debian 8 : Configure Nginx and Passenger to supercharge your PuppetMaster</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/06/22/Debian-8-%3A-Configure-Nginx-and-Passenger-to-supercharge-your-PuppetMaster</link>
        <guid isPermaLink="false">urn:md5:67dac3b40d4c262e3ea9a071eb94d2e6</guid>
        <pubDate>Wed, 22 Jun 2016 21:16:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>jessie</category>
                  <category>mongrel</category>
                  <category>nginx</category>
                  <category>passenger</category>
                  <category>puppet</category>
                  <category>puppetmaster</category>
                  <category>ruby</category>
                <description>&lt;p&gt;The &lt;a href=&quot;http://puppetlabs.com/&quot;&gt;Puppet&lt;/a&gt; master comes by default with a basic WEBrick server. It allow a quick start for those that are not familiar with Puppet, but when the number of Puppet nodes grows, the performances of the default WEBrick server are going down quickly.&lt;/p&gt;

&lt;p&gt;The Puppet documentation show how to configure Apache and Passenger to replace the default WEBrick server, but what if you have a lot of nodes ? What if you want to apply your configuration within minutes, instead of the default half-hour threshold before the agent asks the master if something changed ?&lt;/p&gt;

&lt;p&gt;Or you may just want a fancy Nginx instead of your plain-old-reliable Apache.&lt;/p&gt;

&lt;p&gt;Here is how.&lt;/p&gt;          &lt;h3&gt;Check your hostname&lt;/h3&gt;

&lt;p&gt;Your hostname is the base configuration for your node, you should check that it's correct, otherwise you will run into problems after Puppet installation.&lt;/p&gt;

&lt;pre&gt;
# hostname -f&lt;/pre&gt;

&lt;p&gt;If everything is okay, check your hosts file&lt;/p&gt;

&lt;pre&gt;
# cat /etc/hosts&lt;/pre&gt;

&lt;p&gt;If your hostname is inside your host file, carry on. Otherwise, set it.&lt;/p&gt;

&lt;h3&gt;Install Puppet and Puppetmaster&lt;/h3&gt;

&lt;p&gt;I suppose that you also need the puppet agent installed on the Puppetmaster server.&lt;/p&gt;

&lt;p&gt;Install Puppet and Puppetmaster :&lt;/p&gt;

&lt;pre&gt;
# apt-get install puppet puppetmaster&lt;/pre&gt;

&lt;p&gt;Stop the Puppetmaster :&lt;/p&gt;

&lt;pre&gt;
# service puppetmaster stop&lt;/pre&gt;

&lt;p&gt;Prevent the puppetmaster from starting. Nginx will spawn on the right port instead of the WEBrick server, previously spawn by Puppetmaster service. Edit the file &lt;strong&gt;/etc/defaults/puppetmaster&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
# Start puppetmaster on boot?
START=no&lt;/pre&gt;

&lt;p&gt;Configure the Puppet agent : edit the file &lt;strong&gt;/etc/puppet/puppet.conf&lt;/strong&gt; to point your agent on the master (for instance puppetmaster.example.com).&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;comment&lt;/strong&gt; the two lines that are &quot;needed for passenger&quot;, our configuration don't need them. Actually, &lt;strong&gt;if you keep it, it will not work&lt;/strong&gt;.&lt;/p&gt;

&lt;pre&gt;
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post
&lt;strong&gt;server=puppetmaster.example.com&lt;/strong&gt;

[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
&lt;strong&gt;#ssl_client_header = SSL_CLIENT_S_DN
#ssl_client_verify_header = SSL_CLIENT_VERIFY&lt;/strong&gt;

[agent]
report = true&lt;/pre&gt;

&lt;p&gt;Enable your puppet agent :&lt;/p&gt;

&lt;pre&gt;
# puppet agent --enable&lt;/pre&gt;

&lt;h3&gt;Install Nginx and Passenger&lt;/h3&gt;

&lt;p&gt;We will install the bundle Nginx+Passenger shipped by Phusion repositories.&lt;/p&gt;

&lt;p&gt;Add the key to your keyring :&lt;/p&gt;

&lt;pre&gt;
# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7&lt;/pre&gt;

&lt;p&gt;The Phusion repository uses HTTPS, add HTTPS transport to APT :&lt;/p&gt;

&lt;pre&gt;
# apt-get install apt-transport-https ca-certificates&lt;/pre&gt;

&lt;p&gt;Finally, install Nginx and Passenger :&lt;/p&gt;

&lt;pre&gt;
# apt-get update
# apt-get install nginx-extras passenger&lt;/pre&gt;

&lt;h3&gt;Configure Nginx and Puppetmaster application&lt;/h3&gt;

&lt;p&gt;Edit &lt;strong&gt;/etc/nginx/nginx.conf&lt;/strong&gt; and uncomment the reference to passenger config :&lt;/p&gt;

&lt;pre&gt;
    ##
    # Phusion Passenger config
    ##
    # Uncomment it if you installed passenger or passenger-enterprise
    ##

    include /etc/nginx/passenger.conf;&lt;/pre&gt;

&lt;p&gt;Create the file &lt;strong&gt;/etc/nginx/nginx/sites-available/puppet.conf&lt;/strong&gt; with the following content :&lt;/p&gt;

&lt;pre&gt;
server {
    listen                     8140 ssl;
    server_name                puppet puppetmaster puppetmaster.example.com;

    passenger_enabled          on;
    passenger_app_env          production;

    passenger_set_header       X-Client-Verify  $ssl_client_verify;
    passenger_set_header       X-Client-DN $ssl_client_s_dn;
    passenger_set_header       X-SSL-Subject    $ssl_client_s_dn;
    passenger_set_header       X-SSL-Issuer     $ssl_client_i_dn;

    access_log                 /var/log/nginx/puppet_access.log;
    error_log                  /var/log/nginx/puppet_error.log;

    root                       /etc/puppet/rack/public;

    ssl_certificate            /var/lib/puppet/ssl/certs/puppetmaster.example.com.pem;
    ssl_certificate_key        /var/lib/puppet/ssl/private_keys/puppetmaster.example.com.pem;
    ssl_crl                    /var/lib/puppet/ssl/ca/ca_crl.pem;
    ssl_client_certificate     /var/lib/puppet/ssl/certs/ca.pem;
    ssl_ciphers                'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_prefer_server_ciphers  on;
    ssl_verify_client          optional;
    ssl_verify_depth           1;
    ssl_session_cache          shared:SSL:128m;
    ssl_session_timeout        5m;
}&lt;/pre&gt;

&lt;p&gt;Remove the default virtual host from Nginx as we don't need it :&lt;/p&gt;

&lt;pre&gt;
# rm /etc/nginx/sites-enabled/default&lt;/pre&gt;

&lt;p&gt;And enable your newly created server :&lt;/p&gt;

&lt;pre&gt;
# ln -s /etc/nginx/sites-available/puppet.conf /etc/nginx/sites-enabled/puppet.conf&lt;/pre&gt;

&lt;p&gt;Before restarting Nginx, we will configure the Ruby application for Puppetmaster.&lt;/p&gt;

&lt;p&gt;Create the directory &lt;strong&gt;/etc/puppet/rack&lt;/strong&gt; and its subdirectories &lt;strong&gt;/etc/puppet/rack/public&lt;/strong&gt; and &lt;strong&gt;/etc/puppet/rack/tmp&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;
# mkdir -p /etc/puppet/rack/public /etc/puppet/rack/tmp&lt;/pre&gt;

&lt;p&gt;Create the file &lt;strong&gt;/etc/puppet/rack/config.ru&lt;/strong&gt; with the following content :&lt;/p&gt;

&lt;pre&gt;
# a config.ru, for use with every rack-compatible webserver.
# SSL needs to be handled outside this, though.

# if puppet is not in your RUBYLIB:
# $LOAD_PATH.unshift('/opt/puppet/lib')

$0 = &quot;master&quot;

# Set the PATH in environment variable
ENV['PATH'] = &quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;

# if you want debugging:
# ARGV &amp;lt;&amp;lt; &quot;--debug&quot;

ARGV &amp;lt;&amp;lt; &quot;--rack&quot;

# Rack applications typically don't start as root.  Set --confdir, --vardir,
# --logdir, --rundir to prevent reading configuration from
# ~/ based pathing.
ARGV &amp;lt;&amp;lt; &quot;--confdir&quot; &amp;lt;&amp;lt; &quot;/etc/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--vardir&quot;  &amp;lt;&amp;lt; &quot;/var/lib/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--logdir&quot;  &amp;lt;&amp;lt; &quot;/var/log/puppet&quot;
ARGV &amp;lt;&amp;lt; &quot;--rundir&quot;  &amp;lt;&amp;lt; &quot;/var/run/puppet&quot;
#ARGV &amp;lt;&amp;lt; &quot;--codedir&quot;  &amp;lt;&amp;lt; &quot;/etc/puppet/code&quot;

# always_cache_features is a performance improvement and safe for a master to
# apply. This is intended to allow agents to recognize new features that may be
# delivered during catalog compilation.
ARGV &amp;lt;&amp;lt; &quot;--always_cache_features&quot;

# NOTE: it's unfortunate that we have to use the &quot;CommandLine&quot; class
#  here to launch the app, but it contains some initialization logic
#  (such as triggering the parsing of the config file) that is very
#  important.  We should do something less nasty here when we've
#  gotten our API and settings initialization logic cleaned up.
#
# Also note that the &quot;$0 = master&quot; line up near the top here is
#  the magic that allows the CommandLine class to know that it's
#  supposed to be running master.
#
# --cprice 2012-05-22

require 'puppet/util/command_line'
# we're usually running inside a Rack::Builder.new {} block,
# therefore we need to call run *here*.
run Puppet::Util::CommandLine.new.execute&lt;/pre&gt;

&lt;p&gt;Chown the file for Puppet user :&lt;/p&gt;

&lt;pre&gt;
# chown puppet:puppet /etc/puppet/rack/config.ru&lt;/pre&gt;

&lt;p&gt;And finally, restart Nginx :&lt;/p&gt;

&lt;pre&gt;
# service nginx restart&lt;/pre&gt;

&lt;p&gt;Then, test you configuration by running the agent :&lt;/p&gt;

&lt;pre&gt;
# puppet agent --test&lt;/pre&gt;

&lt;h3&gt;Troubleshooting and errors&lt;/h3&gt;

&lt;h4&gt;Error 500&lt;/h4&gt;

&lt;pre&gt;
Warning: Error 500 on SERVER: Internal Server Error&lt;/pre&gt;

&lt;p&gt;Read the logs at &lt;strong&gt;/var/log/nginx/error.log&lt;/strong&gt; and &lt;strong&gt;/etc/nginx/puppet_error.log&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;Error 403&lt;/h4&gt;

&lt;pre&gt;
Warning: Error 403 on SERVER: Forbidden request: localhost(127.0.0.1) access to /node/puppetmaster.example.com [find] at :119&lt;/pre&gt;

&lt;p&gt;Check that your hostname resolves, and that your host file is clean. In particular, you should have the host name of your server on the same line than localhost :&lt;/p&gt;

&lt;pre&gt;
127.0.0.1    localhost puppetmaster puppetmaster.example.com&lt;/pre&gt;

&lt;p&gt;Also check that your Puppet configuration is correct, in particular check that the two lines &quot;required for Passenger&quot; are commented.&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.puppet.com/puppet/4.5/reference/passenger.html#install-rackpassenger&quot;&gt;[Puppet Doc] Configuring a Puppet Master Server with Passenger and Apache&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.linode.com/docs/websites/ror/ruby-on-rails-nginx-debian-8&quot;&gt;[Linode] Ruby on Rails with Nginx on Debian 8&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.phusionpassenger.com/library/install/nginx/install/oss/jessie/&quot;&gt;[Phusion Passenger] Installing Passenger + Nginx&lt;/a&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;https://www.phusionpassenger.com/library/config/nginx/reference/&quot;&gt;[Phusion Passenger] Configuration reference&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://ask.puppet.com/question/13176/puppet-master-could-not-retrieve-fact-fqdnipaddress/?answer=13351#post-id-13351&quot;&gt;[Ask Puppet] Puppet Master - Could not retrieve fact fqdn/ipaddress&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a class=&quot;question-hyperlink&quot; href=&quot;http://serverfault.com/questions/456680/puppet-master-rest-api-returns-403-when-running-under-passenger-works-when-maste&quot;&gt;Puppet master REST API returns 403 when running under passenger&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;</description>
        
              </item>
          <item>
        <title>&quot;SQLSTATE[HY000] [2002] No such file or directory&quot; for compiled PHP</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/04/19/SQLSTATE%5BHY000%5D-%5B2002%5D-No-such-file-or-directory-for-compiled-PHP</link>
        <guid isPermaLink="false">urn:md5:fe7ea9121022705600cf591fb8363708</guid>
        <pubDate>Tue, 19 Apr 2016 22:52:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>compiled</category>
                  <category>debian</category>
                  <category>mysql</category>
                  <category>php</category>
                <description>          &lt;p&gt;Let's say you connect to MySQL using &quot;localhost&quot;&lt;/p&gt;

&lt;p&gt;Let's say you compiled PHP&lt;/p&gt;

&lt;p&gt;Let's say you didn't specify the --with-mysql-sock= parameter in your configure command when you built mysql&lt;/p&gt;

&lt;p&gt;And let's suppose you cannot connect to MySQL using PHP. CLI works fine, but not CGI.&lt;/p&gt;

&lt;p&gt;Solution : fix the default sockets in php.ini (use your own working socket paths) :&lt;/p&gt;

&lt;pre&gt;
pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock
mysqli.default_socket = /var/run/mysqld/mysqld.sock

# You shouldn't use mysql_ extension, but if you did:
mysql.default_socket = /var/run/mysqld/mysqld.sock&lt;/pre&gt;

&lt;p&gt;I suppose that automatically converting &quot;localhost&quot; to an unix socket is done for performance reason on unix systems.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Debian 8 : Limit SSH users to SFTP</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/01/07/Limit-SSH-users-to-SFTP-only</link>
        <guid isPermaLink="false">urn:md5:d5a47c46eec6232c19a682eae095d7a1</guid>
        <pubDate>Thu, 18 Feb 2016 10:38:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>jessie</category>
                  <category>server</category>
                  <category>sftp</category>
                  <category>ssh</category>
                <description>&lt;p&gt;Let&amp;#8217;s say you want to configure a secure remote file access for you users, but you can&amp;#8217;t use FTPS for some reasons (problems with passive mode and commercial firewalls&amp;#160;? Yes&amp;#160;!). Your only secure solution is either a VPN, or a SFTP access.&lt;/p&gt;&lt;p&gt;SFTP is great, but it may implies giving full command line access to your end users.&amp;nbsp; In order to prevent that, you could set-up a jailed SSH access with &lt;a href=&quot;http://olivier.sessink.nl/jailkit/&quot;&gt;Jailkit&lt;/a&gt; and some &lt;a href=&quot;http://unix.stackexchange.com/questions/198590/what-is-a-bind-mount&quot;&gt;bind mount&lt;/a&gt;, but it&amp;#8217;s not that trivial to configure and to maintain&amp;#160;; and it may not work with software virtualization (Docker, LXCs&amp;#8230;). There is a simpler solution.&lt;/p&gt;&lt;p&gt;The solution is&amp;#160;: use the native chroot and limitations abilities of OpenSSH. Here is how.&lt;/p&gt;          &lt;h3&gt;Warning!&lt;/h3&gt;&lt;p&gt;You should not configure this on your primary SSH access. By doing so, you will simply lock you out of your server.&lt;/p&gt;&lt;p&gt;In this article, we will set up a completely new instance of OpennSSH server, running next to the original, and handling SFTP only.&lt;/p&gt;&lt;h3&gt;1. Setup the secondary SSH access (SFTP-only)&lt;/h3&gt;&lt;p&gt;Create a new configuration file by copying the primary configuration&amp;#160;:&lt;/p&gt;&lt;pre&gt;cp /etc/ssh/sshd_config /etc/ssh/sftp_config&lt;/pre&gt;&lt;p&gt;Now edit the file &lt;strong&gt;/etc/ssh/sftp_config&lt;/strong&gt; and change the listening port (for instance 10022)&amp;#160;:&lt;/p&gt;&lt;pre&gt;Port 10022&lt;/pre&gt;&lt;p&gt;Change the PID file for this new instance, set something meaningful&amp;#160;:&lt;/p&gt;&lt;pre&gt;PidFile /var/run/sftp.pid&lt;/pre&gt;&lt;p&gt;Then add these lines to&amp;nbsp;&lt;strong&gt;/etc/ssh/sftp_config&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no&lt;/pre&gt;&lt;p&gt;Here is a sample of a full configuration&amp;#160;:&lt;/p&gt;&lt;pre&gt;# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
&lt;strong&gt;Port 10022&lt;/strong&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

&lt;strong&gt;PidFile /var/run/sftp.pid&lt;/strong&gt;

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile    %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

&lt;strong&gt;X11Forwarding no&lt;/strong&gt;
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

&lt;strong&gt;Subsystem sftp /usr/lib/openssh/sftp-server
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no&lt;/strong&gt;

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of &quot;PermitRootLogin without-password&quot;.
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
&lt;/pre&gt;&lt;p&gt;Now, let&amp;#8217;s configure autostart. Copy &lt;strong&gt;/lib/systemd/system/ssh.service&lt;/strong&gt; to&amp;nbsp;&lt;strong&gt;/lib/systemd/system/sftp.service&lt;/strong&gt; and adjust settings&amp;#160;:&lt;/p&gt;&lt;pre&gt;[Unit]
Description=&lt;strong&gt;OpenBSD Secure Shell server (SFTP only)&lt;/strong&gt;
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Service]
EnvironmentFile=-/etc/default/ssh
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS -f &lt;strong&gt;/etc/ssh/sftp.conf&lt;/strong&gt;
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target
Alias=&lt;strong&gt;sftp.service&lt;/strong&gt;
&lt;/pre&gt;&lt;p&gt;And enable your service&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl enable sftp.service&lt;/pre&gt;&lt;p&gt;Make sure the symlink&amp;nbsp;&lt;strong&gt;/etc/systemd/system/sftp.service&lt;/strong&gt; is created.&lt;/p&gt;&lt;p&gt;And try to start it&amp;#160;:&lt;/p&gt;&lt;pre&gt;service sftp start&lt;/pre&gt;&lt;h3&gt;2. Reconfigure the primary SSH access&lt;/h3&gt;&lt;p&gt;In order to prevent normal users to log into a full shell, we have to change the primary configuration.&lt;/p&gt;&lt;p&gt;The configuration file should be located in &lt;strong&gt;/etc/ssh/sshd_config&lt;/strong&gt; . Add an AllowUsers or AllowGroups directive to this file&amp;#160;:&lt;/p&gt;&lt;pre&gt;# One or the other but not both!
AllowUsers root admin
#AllowGroups sudo
&lt;/pre&gt;&lt;p&gt;Here is a sample of a full configuration&amp;#160;:&lt;/p&gt;&lt;pre&gt;# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
&lt;strong&gt;Port 22&lt;/strong&gt;
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes
&lt;strong&gt;AllowUsers root admin&lt;/strong&gt;

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile    %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes&lt;/pre&gt;&lt;p&gt;Restart your primary SSH access, but &lt;strong&gt;don&amp;#8217;t close your terminal afterwards&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;service ssh restart&lt;/pre&gt;&lt;p&gt;Now open a new terminal and check that your primary SSH is still working. If not, rollback your configuration.&lt;/p&gt;&lt;h3&gt;3. Conclusion&lt;/h3&gt;&lt;p&gt;Now you should have two SSH sockets listening&amp;#160;: one for everyone using exclusively SFTP, and the other with full SSH access for authorized accounts.&lt;/p&gt;&lt;p&gt;Don&amp;#8217;t hesitate to reply in comments if you encounter problems. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;&lt;h3&gt;Sources&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://wiki.archlinux.org/index.php/SFTP_chroot&quot;&gt;https://wiki.archlinux.org/index.php/SFTP_chroot&lt;/a&gt;&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Add Drush to Jailkit</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2016/02/16/Add-Drush-to-Jailkit</link>
        <guid isPermaLink="false">urn:md5:956e4551f046b5202f2d1531357cd1d1</guid>
        <pubDate>Tue, 16 Feb 2016 10:16:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>drush</category>
                  <category>jailkit</category>
                <description>          &lt;p&gt;Here is the configuration I use to make &lt;a href=&quot;http://www.drush.org&quot;&gt;Drush&lt;/a&gt; working inside a &lt;a href=&quot;http://olivier.sessink.nl/jailkit/&quot;&gt;Jailkit&lt;/a&gt; chrooted shell&amp;#160;:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;/etc/jailkit/jk_init.ini&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;[php]
comment = the PHP interpreter and libraries
executables = /usr/bin/php5, /usr/bin/php
directories = /usr/lib/php5, /usr/share/php, /usr/share/php5, /etc/php5, /usr/share/php-geshi, [B]/usr/share/zoneinfo[/B]
includesections = env

[env]
comment = environment variables
executables = /usr/bin/env

[mysql-client]
comment = mysql client
executables = /usr/bin/mysql
paths = /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18

[drush]
comment = drush (drupal command line)
includesections = php, mysql-client, uidbasics, netbasics
directories = /usr/share/zoneinfo, /etc/ssl/certs, /usr/share/ca-certificates&lt;/pre&gt;&lt;p&gt;Once the jailed shell works, add the Drush dependencies to the jail&amp;#160;:&lt;/p&gt;&lt;pre&gt;jk_init -v -c /etc/jailkit/jk_init.ini -f -k -j /absolute/path/to/jail/ drush&lt;/pre&gt;</description>
        
              </item>
          <item>
        <title>Set-up SQL quarantine with Amavisd-new and ISPConfig</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig</link>
        <guid isPermaLink="false">urn:md5:c449e2fbaef8eadc5d8276ac89e472d3</guid>
        <pubDate>Sun, 06 Dec 2015 16:56:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>amavis</category>
                  <category>debian</category>
                  <category>ISPConfig</category>
                  <category>jessie</category>
                  <category>mail</category>
                  <category>quarantine</category>
                  <category>server</category>
                  <category>spam</category>
                  <category>sql</category>
                <description>&lt;p&gt;It's documented, but it took me two days to do it correctly, so here is how to reconfigure an ISPConfig installation of Amavis to store quarantined mail in SQL database, in order to install a quarantine viewer like Mailzu.&lt;/p&gt;          &lt;h3&gt;1. Prerequisites&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;A working Postfix+Amavis stack with ISPConfig&lt;/li&gt;
	&lt;li&gt;A working SQL (PostgreSQL, MySQL...) database&lt;/li&gt;
	&lt;li&gt;Optional : a working mail server with PHP (for Mailzu)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Jump to &lt;a href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig#installation&quot;&gt;Installation&lt;/a&gt; if you know what you are doing.&lt;/p&gt;

&lt;h3&gt;2. Off-subject generic explanations&lt;/h3&gt;

&lt;h4&gt;2.1 Amavis and ISPConfig policies&lt;/h4&gt;

&lt;figure style=&quot;float: right; margin: 0 0 1em 1em;&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_tag_levels.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy_tag_levels.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/.ispconfig_mail_spamfilter_policy_tag_levels_s.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig policies, Tag-Levels&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;In a default ISPConfig installation per-user ISPConfig policies are loaded. The configuration file for Amavis, written by ISPConfig contains :&lt;/p&gt;

&lt;pre&gt;
@lookup_sql_dsn =
   ( ['DBI:mysql:database=dbispconfig;host=127.0.0.1;port=3306', 'ispconfig', 'xxxx'] );
$sql_select_policy =
   'SELECT *,spamfilter_users.id'.
   ' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
   ' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';
$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
    ' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
    ' ORDER BY spamfilter_wblist.priority DESC';&lt;/pre&gt;

&lt;p&gt;It means that whatever you would set as&amp;nbsp;&lt;strong&gt;$sa_spam_subject_tag&lt;/strong&gt;, &lt;strong&gt;$sa_tag_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_tag2_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_kill_level_deflt&lt;/strong&gt;, &lt;strong&gt;$sa_dsn_cutoff_level&lt;/strong&gt;, it will be overridden by per-user policies.&lt;/p&gt;

&lt;p&gt;The ISPConfig policies can be changed in tab Email =&amp;gt; Spamfilter =&amp;gt; Policy in ISPConfig panel. If you struggle wondering why your message keeps getting smashed at level 4.5, look at the sa_tag_level in policies. We will have to change values in that policies, to make the SQL quarantine working.&lt;/p&gt;

&lt;h4&gt;2.2 Lookup DSN and Storage DSN&lt;/h4&gt;

&lt;p&gt;DSN (Data Source Name) are the connection strings with host, username, and password, used to connect to databases.&lt;/p&gt;

&lt;p&gt;Amavis can set two DSN : one for Policies lookup (used to retrieve ISPConfig policies from Panel), and one for storage of mail meta informations and quarantine. We will use the Storage DSN to set up a secondary database for quarantine storage, to not mess with existing ISPConfig database.&lt;/p&gt;

&lt;h4&gt;2.3 Levels and cutoffs&lt;/h4&gt;

&lt;p&gt;Amavis uses Spamassassin to score the mail, in order to decide what to do with it. The category of test (spam test, antivirus, etc) and the score along with levels determines the actions Amavis will trigger, and the final destiny where the mail belongs.&lt;/p&gt;

&lt;p&gt;Spamassassin levels are :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;tag_level&lt;/strong&gt; : a message above that score will be tagged with &lt;strong&gt;X-Spam-Status&lt;/strong&gt;, &lt;strong&gt;X-Spam-Score&lt;/strong&gt; and &lt;strong&gt;X-Spam-Level&lt;/strong&gt; headers.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;tag2_level&lt;/strong&gt; : a message above that score will be marked &lt;strong&gt;as X-Spam-Status: Yes&lt;/strong&gt; and the subject is changed if &lt;strong&gt;sa_spam_modifies_subj&lt;/strong&gt; is set to true.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;kill_level&lt;/strong&gt; : a message above that score is taken to the &lt;strong&gt;final_spam_destiny&lt;/strong&gt;, and quarantined, it will not be delivered unless &lt;strong&gt;D_PASS&lt;/strong&gt; is set to &lt;strong&gt;final_spam_destiny&lt;/strong&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;dsn_cutoff_level&lt;/strong&gt; : a message above that level will never trigger a bounce or a reject, whatever &lt;strong&gt;spam_destiny&lt;/strong&gt; is.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;quarantine_cutoff_level&lt;/strong&gt; : a message above that level will not be quarantined.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;2.4 Final &lt;span class=&quot;gt-baf-back&quot;&gt;destinations&lt;/span&gt;&lt;/h4&gt;

&lt;p&gt;Once the message is categorized by Amavis tests (through SpamAssassin, ClamAV, etc), Amavis decides if it should be delivered to user mailbox or not, and if a bounce will be issued.&lt;/p&gt;

&lt;p&gt;This is the purpose of &lt;strong&gt;$final_virus_destiny&lt;/strong&gt;, &lt;strong&gt;$final_spam_destiny&lt;/strong&gt;, &lt;strong&gt;$final_banned_destiny&lt;/strong&gt;, &lt;strong&gt;$final_bad_header_destiny&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;They can take the following values :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;D_PASS&lt;/strong&gt; : mail will be delivered to inbox.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_BOUNCE&lt;/strong&gt; : mail will not be delivered, and a &lt;em&gt;delivery status notification&lt;/em&gt; will be returned by Postifx to sender (except if the score exceeds the &lt;strong&gt;dsn_cutoff&lt;/strong&gt; level)&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_REJECT&lt;/strong&gt; : Postfix will answer REJECT to the distant mail server, and the distant mail server may produce a &lt;em&gt;delivery status notification&lt;/em&gt; to the user&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;D_DISCARD&lt;/strong&gt; : forgive and forget : the mail will not be delivered and the sender is not informed. The mail may be quarantined if the &lt;strong&gt;quarantine_cutoff&lt;/strong&gt; level is not exceeded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;&lt;a name=&quot;installation&quot;&gt;3. Installation&lt;/a&gt;&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;For Amavis : Nothing ! Amavis comes out-of-the-box with SQL storage.&lt;/li&gt;
	&lt;li&gt;For Mailzu : see &lt;a href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/12/05/Set-up-SQL-quarantine-with-Amavisd-new-and-ISPConfig#mailzu&quot;&gt;Mailzu&lt;/a&gt; section.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;4. Configuration&lt;/h3&gt;

&lt;h4&gt;4.1 Database&lt;/h4&gt;

&lt;p&gt;Create an user and a database for quarantine storage :&lt;/p&gt;

&lt;pre&gt;
# mysql -u root -p
mysql&amp;gt; CREATE DATABASE amavis_storage;
mysql&amp;gt; CREATE USER 'amavis_storage'@'localhost' IDENTIFIED BY 'xxxx';
mysql&amp;gt; GRANT ALL PRIVILEGES ON amavis_storage.* TO 'amavis_storage'@'localhost';
mysql&amp;gt; FLUSH PRIVILEGES;&lt;/pre&gt;

&lt;p&gt;Load the initial schema from Amavis docs (usually located in &lt;strong&gt;/usr/share/doc/amavisd-new&lt;/strong&gt;/ ).&lt;/p&gt;

&lt;p&gt;Delete unnecessary tables, as we will be using this database only for mail storage and not for lookups :&lt;/p&gt;

&lt;pre&gt;
# mysql -u amavis_storage -p amavis_storage
mysql&amp;gt; DROP TABLE users;
mysql&amp;gt; DROP TABLE mailaddr;
mysql&amp;gt; DROP TABLE policy;
mysql&amp;gt; DROP TABLE wblist;
&lt;/pre&gt;

&lt;p&gt;Nota Bene : while executing &lt;strong&gt;DROP TABLE users&lt;/strong&gt;, don't be silly, and do not remove mysql users database.&lt;/p&gt;

&lt;h4&gt;4.2 Amavis&lt;/h4&gt;

&lt;p&gt;Update your Amavis configuration &lt;strong&gt;/etc/amavis/conf.d/50_user&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
@storage_sql_dsn = ( ['DBI:mysql:database=amavis_storage;host=127.0.0.1;port=3306', 'amavis_storage', 'xxxx'] );  # none, same, or separate database

# Quarantine SPAM into SQL server.
$spam_quarantine_to = 'spam-quarantine';
$spam_quarantine_method = 'sql:';

# Quarantine VIRUS into SQL server.
$virus_quarantine_to = 'virus-quarantine';
$virus_quarantine_method = 'sql:';

# Quarantine BANNED message into SQL server.
$banned_quarantine_to = 'banned-quarantine';
$banned_files_quarantine_method = 'sql:';

# Quarantine Bad Header message into SQL server.
$bad_header_quarantine_method = 'sql:';
$bad_header_quarantine_to = 'badheader-quarantine';

# Do not store non-quarantined messages info
# You can set it to 1 (the default) to test if Amavis is filling correctly the tables maddr, msgs, and msgcrpt
$sql_store_info_for_all_msgs = 0;

#
# SQL Select statements
#

$sql_select_policy =
   'SELECT *,spamfilter_users.id'.
   ' FROM spamfilter_users LEFT JOIN spamfilter_policy ON spamfilter_users.policy_id=spamfilter_policy.id'.
   ' WHERE spamfilter_users.email IN (%k) ORDER BY spamfilter_users.priority DESC';

$sql_select_white_black_list = 'SELECT wb FROM spamfilter_wblist'.
    ' WHERE (spamfilter_wblist.rid=?) AND (spamfilter_wblist.email IN (%k))' .
    ' ORDER BY spamfilter_wblist.priority DESC';

#
# Quarantine settings
#

$final_virus_destiny = D_BOUNCE;
$final_spam_destiny = D_DISCARD;
$final_banned_destiny = D_BOUNCE;
$final_bad_header_destiny = D_PASS;

# Default settings, we st this very high to not filter aut emails accidently
$sa_spam_subject_tag = '[SPAM] ';
$sa_tag_level_deflt  = 20.0;  # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 60.0; # add 'spam detected' headers at that level
$sa_kill_level_deflt = 60.0; # triggers spam evasive actions
$sa_dsn_cutoff_level = 100;   # spam level beyond which a DSN is not sent
#$sa_debug = 1;

#
# Disable spam and virus notifications for the admin user.
# Can be overridden by the policies in mysql
#

$virus_admin = undef;
$spam_admin = undef;

#
# Enable Logging
#

$DO_SYSLOG = 1;
$LOGFILE = &quot;/var/log/amavis.log&quot;;  # (defaults to empty, no log)

# Set the log_level to 5 for debugging
$log_level = 0;                # (defaults to 0)&lt;/pre&gt;

&lt;h4&gt;4.3 ISPConfig policies&lt;/h4&gt;

&lt;p&gt;Remember that ISPconfig policies are overriding a lot of our configuration in &lt;strong&gt;50_user&lt;/strong&gt;. In order to majke the quarantine work, you have to reconfigure all the available policies in ISPConfig Panel.&lt;/p&gt;

&lt;p&gt;Look at your policies list, you have to change the quarantine settings for every policies :&lt;/p&gt;

&lt;figure style=&quot;{figureStyle}&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig Mail Spamfilter Policy&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h4&gt;When editing a policy, on the Quarantine tab, set the destinations :&lt;/h4&gt;

&lt;figure style=&quot;{figureStyle}&quot;&gt;&lt;a class=&quot;media-link&quot; href=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_quarantine.png&quot;&gt;&lt;img alt=&quot;ispconfig_mail_spamfilter_policy_quarantine.png&quot; class=&quot;media&quot; src=&quot;https://uname.pingveno.net/blog/public/captures/ispconfig/ispconfig_mail_spamfilter_policy_quarantine.png&quot; /&gt;&lt;/a&gt;

&lt;figcaption&gt;ISPConfig Mail Spamfilter Policy Quarantine destinations&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;If you do not fill something in these fields, Amavis will not store quarantined mails in SQL database, and will just discard it !&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These fields correspond to the &lt;strong&gt;virus_quarantine_to&lt;/strong&gt;, &lt;strong&gt;spam_quarantine_to&lt;/strong&gt;, &lt;strong&gt;banned_quarantine_to&lt;/strong&gt;, &lt;strong&gt;bad_header_quarantine_to&lt;/strong&gt; variables in Amavis configuration, and an empty value is overriding those we set in Amavis configuration.&lt;/p&gt;

&lt;h4&gt;4.4 Test&lt;/h4&gt;

&lt;p&gt;Send some spam to your server, check if the tables are populated :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM maddr;&lt;/pre&gt;

&lt;p&gt;Check if meta informations are populated :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM msgs;
mysql&amp;gt; SELECT * FROM msgrcpt;&lt;/pre&gt;

&lt;p&gt;And if quarantine is filling :&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM quarantine;&lt;/pre&gt;

&lt;h3&gt;5. Cleanup !&lt;/h3&gt;

&lt;p&gt;You should not &quot;setup and forget&quot; your quarantine SQL storage. Messages has to be deleted periodically, otherwise your database will grow forever. Look at the documentaion in &lt;strong&gt;/usr/share/docs/amavisd-new&lt;/strong&gt; to make a cronjob like this :&lt;/p&gt;

&lt;pre&gt;
#!/bin/bash

SQL_HOST=&quot;localhost&quot;;
SQL_LOGIN=&quot;amavis_storage&quot;
SQL_PASSWORD=&quot;xxxx&quot;
SQL_DB=&quot;amavis_storage&quot;

mysql --user=&quot;$SQL_LOGIN&quot; --password=&quot;$SQL_PASSWORD&quot; --host=&quot;$SQL_HOST&quot; $SQL_DB -e &quot; \
  DELETE FROM msgs WHERE time_num &amp;lt; UNIX_TIMESTAMP() - 30*24*3600; \
  DELETE FROM msgrcpt WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=msgrcpt.mail_id); \
  DELETE FROM quarantine WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=quarantine.mail_id); \
  DELETE FROM maddr WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE sid=id) AND NOT EXISTS (SELECT 1 FROM msgrcpt WHERE rid=id); \
&quot;
&lt;/pre&gt;

&lt;h3&gt;&lt;a name=&quot;mailzu&quot;&gt;6. Mailzu&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;I have to admit, Mailzu seems a bit obsolete as I had to patch to make it working with Amavis 3.3 tables. But it still works pretty well for a simple task like reading and releasing quarantine mails.&lt;/p&gt;

&lt;h4&gt;6.1 Installation&lt;/h4&gt;

&lt;p&gt;Download the source files at &lt;a href=&quot;http://sourceforge.net/projects/mailzu/&quot;&gt;http://sourceforge.net/projects/mailzu/&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;62. Patch&lt;/h4&gt;

&lt;p&gt;The existing Mailzu source code is quite old, and the schema of Amavis SQL tables changed. Download and apply &lt;a href=&quot;http://sourceforge.net/p/mailzu/patches/10/&quot;&gt;this patch&lt;/a&gt; in to make Mailzu work.&lt;/p&gt;

&lt;h4&gt;6.3 Configuration&lt;/h4&gt;

&lt;p&gt;I suppose that you know how to spawn PHP with CGI to serve the Mailzu files.&lt;/p&gt;

&lt;p&gt;Configure your database login and password in &lt;strong&gt;config/config.php&lt;/strong&gt; :&lt;/p&gt;

&lt;pre&gt;
$conf['db']['dbType'] = 'mysql';
$conf['db']['dbUser'] = 'amavis_storage';
$conf['db']['dbPass'] = 'xxxx';
$conf['db']['dbName'] = 'amavis_storage';
$conf['db']['hostSpec'] = 'localhost:3306';&lt;/pre&gt;

&lt;p&gt;I am using IMAP login to authenticate in Mailzu. Unfortunately, I had to turn off SSL authentication, as it wasn't working. Here is my configuration :&lt;/p&gt;

&lt;pre&gt;
$conf['auth']['serverType'] = 'imap';
$conf['auth']['imap_hosts'] = array( 'localhost:143' );
$conf['auth']['imap_type'] = 'imaptls';
$conf['auth']['imap_domain_name'] = 'example.com';&lt;/pre&gt;

&lt;p&gt;Don't forget to set yourself &quot;super&quot; :&lt;/p&gt;

&lt;pre&gt;
$conf['auth']['s_admins'] = array ('me@example.com');&lt;/pre&gt;

&lt;p&gt;And to set your web uri :&lt;/p&gt;

&lt;pre&gt;
$conf['app']['weburi'] = 'https://example.com/mailzu';&lt;/pre&gt;

&lt;h4&gt;6.4 Configure in-app release&lt;/h4&gt;

&lt;p&gt;Mailzu can also release quarantined mail. I did not implement this function, but you have to set up the amavisd-release internface on an inet socket on port 9998, instead of the existing unix socket located at &lt;strong&gt;/var/lib/amavis/amavisd.sock&lt;/strong&gt; . &lt;a href=&quot;https://www.ijs.si/software/amavisd/amavisd-new-docs.html#quar-release&quot;&gt;Read more&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.iredmail.org/docs/amavisd.sql.db.html&quot;&gt;Explanation of Amavisd SQL database&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://blog.bravi.org/?p=683&quot;&gt;AMaViS: deal with SPAM, Viruses, Banned attachments, and Bad headers&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.ijs.si/software/amavisd/amavisd-new-docs.html#quarantine&quot;&gt;amavisd-new documentation bits and pieces&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.raygibson.net/kb/amavis/amavisd.conf&quot;&gt;amavis.conf&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/projects/mailzu/&quot;&gt;Mailzu&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://sourceforge.net/p/mailzu/patches/10/&quot;&gt;Mailzu patch for Amavis 2.7.0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
          <enclosure url="/blog/public/code/sql/amavis_storage_partial_schema.sql" length="4518" type="application/octet-stream" />
        
              </item>
          <item>
        <title>Configurer dibbler-client pour IPv6 sur une Dedibox (Online.net) avec Debian 8 (Jessie)</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/10/21/Configurer-dibbler-client-pour-IPv6-sur-une-Dedibox-%28Online.net%29-avec-Debian-8-%28Jessie%29</link>
        <guid isPermaLink="false">urn:md5:68ab8bab67fba7928f19774250094c5e</guid>
        <pubDate>Wed, 21 Oct 2015 14:24:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>dedibox</category>
                  <category>dibbler</category>
                  <category>jessie</category>
                  <category>online</category>
                  <category>proxmox</category>
                  <category>server</category>
                <description>          &lt;p&gt;La documentation d&amp;#8217;Online pour IPv6 ne traite pas le cas de Debian, Ubuntu, ou toute distribution utilisant systemd (CentOS6, etc). La documention doit être étendue pour ajouter le service sysetmd au démarrage, en lieu et place de l&amp;#8217;init script.&lt;/p&gt;&lt;h3&gt;Vérifiez que l&amp;#8217;IPv6 est activé&lt;/h3&gt;&lt;p&gt;Cela devrait normalement être le cas, puisque le noyau par défaut de Debian 8 inclut nativement IPv6 et ne peut pas être désactivé. Mais au cas où vous ne verriez pas le link-local sur vos interfaces&amp;#160;:&lt;/p&gt;&lt;p&gt;Changer dans &lt;code&gt;/etc/modprobe.d/local.conf :&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;options ipv6 disable=0&lt;/pre&gt;&lt;p&gt;Ajouter dans &lt;code&gt;/etc/modules :&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;ipv6&lt;/pre&gt;&lt;p&gt;Il faudra sans doute redémarrer pour appliquer les changments.&lt;/p&gt;&lt;h3&gt;Récupérez votre préfixe et votre DUID depuis la console d&amp;#8217;Online&lt;/h3&gt;&lt;p&gt;Vous devez &lt;a href=&quot;https://console.online.net/fr/assistance/ticket/list&quot;&gt;demander l&amp;#8217;activation de IPv6 au support&lt;/a&gt; et créer votre /64&amp;#160;&lt;a href=&quot;https://console.online.net/fr/network/&quot;&gt;dans la console d&amp;#8217;Online&lt;/a&gt; pour obtenir votre DUID.&lt;/p&gt;&lt;p&gt;Créez un /64 et n&amp;#8217;utilisez pas le /48 ou le 56 directement, vous pourriez le regretter si vous souhaitez redécouper le réseau. Vous n&amp;#8217;avez qu&amp;#8217;un seul /48 par compte, un /56 pour chaque serveur, et un /64 pour chaque failover souscrit.&lt;/p&gt;&lt;h3&gt;Configurez l&amp;#8217;interface réseau&lt;/h3&gt;&lt;p&gt;Encore une fois, c&amp;#8217;est sans doute facultatif puisque Dibbler reconfigure l&amp;#8217;interface lorsqu&amp;#8217;il se lance, donc explicitons ça dans le fichier &lt;strong&gt;/etc/network/interfaces&lt;/strong&gt;, juste au cas où&amp;#160;:&lt;/p&gt;&lt;pre&gt;iface eth0 inet6 static
    address your_ipv6_address
    netmask 64
&amp;nbsp;&amp;nbsp; &amp;nbsp;accept_ra 2
&lt;/pre&gt;&lt;h3&gt;Notes sur Proxmox et le forwarding&lt;/h3&gt;&lt;p&gt;Sous Proxmox on travaille sur l&amp;#8217;interface bridge, c&amp;#8217;est &lt;strong&gt;vmbr0&lt;/strong&gt; et non pas eth0.&lt;/p&gt;&lt;p&gt;Si le forwarding est activé, vous devez forcer le &lt;strong&gt;accept_ra&lt;/strong&gt; à &lt;strong&gt;2&lt;/strong&gt;, une valeur de 1 fera ignorer les router advertisements lorsque le forwarding est activé. &lt;a href=&quot;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&quot;&gt;Explications&lt;/a&gt;. Ajoutez dans sysctl.conf&amp;#160;:&lt;/p&gt;&lt;pre&gt;net.ipv6.conf.vmbr0.accept_ra = 2&lt;/pre&gt;&lt;p&gt;Notez bien que dans le cas où vous adressez vos machines virtuelles en IPv6 vous ne &lt;strong&gt;devez pas brancher l&amp;#8217;interface IPv6 de vos VM directement sur l&amp;#8217;interface vmbr0&lt;/strong&gt;. &lt;a href=&quot;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&quot;&gt;Voilà pourquoi&lt;/a&gt;.&lt;/p&gt;&lt;h3&gt;Compilez et installez Dibbler&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Téléchargez &lt;a href=&quot;http://klub.com.pl/dhcpv6/dibbler/dibbler-1.0.1.tar.gz&quot;&gt;Dibbler 1.0.1&lt;/a&gt; à partir du &lt;a href=&quot;http://klub.com.pl/dhcpv6/#DOWNLOAD&quot;&gt;site officiel&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Installez build-essential&amp;#160;: &lt;code&gt;apt-get install build-essential&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Décompressez Dibbler&amp;#160;: &lt;code&gt;tar -xzf dibbler-1.0.1.tar.gz &amp;amp;&amp;amp; cd dibbler-1.0.1&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Compilez et installez Dibbler&amp;#160;: &lt;code&gt;./configure &amp;amp;&amp;amp; ./make&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Configurez Dibbler&lt;/h3&gt;&lt;p&gt;Créez les dossiers et fichiers de configuration comme le précise la documentation&amp;#160;:&lt;/p&gt;&lt;p&gt;Configurez le DUID dans &lt;strong&gt;/var/lib/dibbler/client-duid&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;mkdir /var/lib/dibbler/
touch /var/lib/dibbler/client-duid
chmod 640 /var/lib/client-duid
# Set up you duid in client-duid
vim /var/lib/client-duid
&lt;/pre&gt;&lt;p&gt;Configurez &lt;strong&gt;/etc/dibbler/client.conf&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;mkdir /etc/dibbler
vim /etc/dibbler/client.conf&lt;/pre&gt;&lt;p&gt;Voici le contenu de mon &lt;strong&gt;client.conf&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;auth-protocol reconfigure-key
auth-replay monotonic
auth-methods digest-hmac-md5
duid-type duid-ll
inactive-mode
log-level 8
iface eth0 {
    pd
    ia
}
&lt;/pre&gt;&lt;p&gt;Encore une fois, c&amp;#8217;est à adapter en fonction du nom de votre interface.&lt;/p&gt;&lt;p&gt;Démarrez le client pour tester la connectivité&amp;#160;:&lt;/p&gt;&lt;pre&gt;dibbler-client run&lt;/pre&gt;&lt;p&gt;Pour vérifier que Dibbler a configuré l&amp;#8217;interface, pressez CTRL+Z pour suspendre le processus et vérifiez que l&amp;#8217;IP et les routes sont bien configurées. Tapez la commande &amp;#8220;fg&amp;#8221; pour retourner au processus en cours d&amp;#8217;exécution, et tapez CTRL+C pour stopper Dibbler.&lt;/p&gt;&lt;p&gt;Si pendant l&amp;#8217;opération les routes et les IPs sont incorrectes, vérifiez que votre pare feu accepte les connexions entrantes par le port 546 UDP.&lt;/p&gt;&lt;h3&gt;Configurez Dibbler au démarrage&lt;/h3&gt;&lt;p&gt;Cette section est différente de la documentation d&amp;#8217;Online.&lt;/p&gt;&lt;p&gt;Avant systemd, le système d&amp;#8217;init par dépendances se contentait d&amp;#8217;un script dans /etc/init.d/. Avec systemd, il faut créer un fichier &lt;strong&gt;service&lt;/strong&gt; dans &lt;strong&gt;/etc/systemd/system/&lt;/strong&gt; .&lt;/p&gt;&lt;p&gt;Créez le fichier suivant&amp;#160;: &lt;strong&gt;/etc/systemd/system/dibbler.service&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;[Unit]
Description=Dibbler
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/sbin/dibbler-client start
ExecStop=/usr/local/sbin/dibbler-client stop
PrivateTmp=true
NonBlocking=yes

[Install]
WantedBy=multi-user.target&lt;/pre&gt;&lt;p&gt;Lancez la commande suivante pour que systemd lise le fichier&amp;nbsp;&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl daemon-reload&lt;/pre&gt;&lt;p&gt;Et activez le service&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl enable dibbler.service&lt;/pre&gt;&lt;p&gt;Et essayez de le lancer pour la première fois&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl start dibbler.service&lt;/pre&gt;&lt;p&gt;Vérifions que tout est correct&amp;#160;:&lt;/p&gt;&lt;pre&gt;service dibbler status
ifconfig
route -6
ping6 whatever-you-want.com&lt;/pre&gt;&lt;p&gt;Si tout va bien, redémarrez et l&amp;#8217;IPv6 fonctionnera dès le démarrage&amp;#160;! &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;&lt;p&gt;Addendum&amp;#160;: juste au cas où, n&amp;#8217;utilisez pas resolvconf pour pousser les DNS IPv6 automatiquement, conservez autant que possible vos DNS IPv4. Ça serait tellement dommage que votre connectivité IPv6 saute et que vous vous retrouviez sans DNS (oui ça m&amp;#8217;est arrivé&amp;#8230;).&lt;/p&gt;&lt;h3&gt;Sources&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://documentation.online.net/en/serveur-dedie/reseau/ipv6-prefix&quot;&gt;http://documentation.online.net/en/serveur-dedie/reseau/ipv6-prefix&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.lowendtalk.com/discussion/48591/configuring-ipv6-for-proxmox-kvm-on-dedibox-online-net&quot;&gt;http://www.lowendtalk.com/discussion/48591/configuring-ipv6-for-proxmox-kvm-on-dedibox-online-net&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd&quot;&gt;http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://sulek.fr/index.php?article60/configuration-ipv6-pour-une-dedibox-sous-centos-7&quot;&gt;https://sulek.fr/index.php?article60/configuration-ipv6-pour-une-dedibox-sous-centos-7&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&quot;&gt;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&quot;&gt;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Configure dibbler-client for IPV6 networking on Dedibox (or any Online.net) servers with Debian 8 (Jessie)</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/10/21/Configure-dibbler-for-IPV6-networking-on-Dedibox-%28or-any-Online.net%29-servers-with-Debian-8-%28Jessie%29</link>
        <guid isPermaLink="false">urn:md5:cf27b5e56650bb4963d6a1f71966a199</guid>
        <pubDate>Wed, 21 Oct 2015 12:50:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>dedibox</category>
                  <category>dibbler</category>
                  <category>jessie</category>
                  <category>online</category>
                  <category>proxmox</category>
                  <category>server</category>
                <description>          &lt;p&gt;The &lt;a href=&quot;http://documentation.online.net/en/serveur-dedie/reseau/ipv6-prefix&quot;&gt;Online documentation for IPv6&lt;/a&gt; is not dealing with the case of Debian 8, Ubuntu, or any distribution using systemd. Systemd replaces upstart, so the procedure has to be extended to add systemd service for startup, replacing the previoux behavior that was using init scripts.&lt;/p&gt;&lt;h3&gt;Ensure that you are IPv6-proof&lt;/h3&gt;&lt;p&gt;It should be the case as Debian 8 is shipping a kernel with native IPv6, but just to be sure&amp;#160;:&lt;/p&gt;&lt;p&gt;In &lt;code&gt;/etc/modprobe.d/local.conf :&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;options ipv6 disable=0&lt;/pre&gt;&lt;p&gt;In &lt;code&gt;/etc/modules :&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;ipv6&lt;/pre&gt;&lt;p&gt;You may have to reboot in order to apply the changes.&lt;/p&gt;&lt;h3&gt;Set up your IPv6 prefix and get your DUID on Online console&lt;/h3&gt;&lt;p&gt;You have to &lt;a href=&quot;https://console.online.net/fr/assistance/ticket/list&quot;&gt;request IPv6 activation to support&lt;/a&gt; and create your /64&amp;#160;&lt;a href=&quot;https://console.online.net/fr/network/&quot;&gt;on Online console&lt;/a&gt; before getting your DUID working.&lt;/p&gt;&lt;p&gt;Make a /64 and do not use your /48 or your /56 directly, as you may regret it. You can have only one /48 by account, one /56 by server, and one /64 by IP failover (the /48 is divided to make the /56 and so on).&lt;/p&gt;&lt;h3&gt;Configure your network interface&lt;/h3&gt;&lt;p&gt;It may not be mandatory as Dibbler will reconfigure your interface, but you have to ensure that you accept router advertisements. Add to &lt;strong&gt;/etc/network/interfaces&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;iface eth0 inet6 static
    address your_ipv6_address
    netmask 64
&amp;nbsp;&amp;nbsp; &amp;nbsp;accept_ra 2
&lt;/pre&gt;&lt;h3&gt;Notes about Proxmox and forwarding&lt;/h3&gt;&lt;p&gt;On Proxmox, you are working on the bridge interface, it should be &lt;strong&gt;vmbr0&lt;/strong&gt; instead of eth0.&lt;/p&gt;&lt;p&gt;If you enabled forwarding on this interface (to give your VM an access to IPv6 network), you have to force the &lt;strong&gt;accept_ra&lt;/strong&gt; to &lt;strong&gt;2&lt;/strong&gt;, while the default value of 1 wil make your Debian to ignore router advertisements when forwarding is enabled&amp;#160;! &lt;a href=&quot;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&quot;&gt;Read more&lt;/a&gt;. Add to sysctl.conf&amp;#160;:&lt;/p&gt;&lt;pre&gt;net.ipv6.conf.vmbr0.accept_ra = 2&lt;/pre&gt;&lt;p&gt;Also &lt;strong&gt;do not set the IPv6 interface of your VM to vmbr0&lt;/strong&gt;, as you can break your network access. &lt;a href=&quot;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&quot;&gt;Read more&lt;/a&gt;.&lt;/p&gt;&lt;h3&gt;Compile and install Dibbler&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Download &lt;a href=&quot;http://klub.com.pl/dhcpv6/dibbler/dibbler-1.0.1.tar.gz&quot;&gt;Dibbler 1.0.1&lt;/a&gt; from the &lt;a href=&quot;http://klub.com.pl/dhcpv6/#DOWNLOAD&quot;&gt;offical website&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Install build-essential&amp;#160;: &lt;code&gt;apt-get install build-essential&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Extract Dibbler&amp;#160;: &lt;code&gt;tar -xzf dibbler-1.0.1.tar.gz &amp;amp;&amp;amp; cd dibbler-1.0.1&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Compile and install Dibbler&amp;#160;: &lt;code&gt;./configure &amp;amp;&amp;amp; ./make&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Configure Dibbler&lt;/h3&gt;&lt;p&gt;Make the directories and set up according to the documentation&amp;#160;:&lt;/p&gt;&lt;p&gt;Set up duid&amp;#160;:&lt;/p&gt;&lt;pre&gt;mkdir /var/lib/dibbler/
touch /var/lib/dibbler/client-duid
chmod 640 /var/lib/client-duid
# Set up you duid in client-duid
vim /var/lib/client-duid
&lt;/pre&gt;&lt;p&gt;Set up client.conf&amp;#160;:&lt;/p&gt;&lt;pre&gt;mkdir /etc/dibbler
vim /etc/dibbler/client.conf&lt;/pre&gt;&lt;p&gt;The content of my client.conf&amp;#160;:&lt;/p&gt;&lt;pre&gt;auth-protocol reconfigure-key
auth-replay monotonic
auth-methods digest-hmac-md5
duid-type duid-ll
inactive-mode
log-level 8
iface eth0 {
    pd
    ia
}
&lt;/pre&gt;&lt;p&gt;Note that if your interface name is different you have to change it accordingly. For instance, on a Proxmox host server, it should be &lt;strong&gt;vmbr0&lt;/strong&gt; instead of eth0.&lt;/p&gt;&lt;p&gt;Start dibbler to try the connectivity&amp;#160;:&lt;/p&gt;&lt;pre&gt;dibbler-client run&lt;/pre&gt;&lt;p&gt;Hit CTRL+Z to suspend the process and check that the IP and routes are configured. Type the command &amp;#8220;fg&amp;#8221; to get back to the running process and hit CTRL+C to stop it.&lt;/p&gt;&lt;p&gt;If it doesn&amp;#8217;t work, check your firewall, dibbler needs to listen port 546 UDP.&lt;/p&gt;&lt;h3&gt;Set Dibbler at startup&lt;/h3&gt;&lt;p&gt;This section differs from Online documentation.&lt;/p&gt;&lt;p&gt;Before systemd, the dependency-based boot sequence only needed an init script, for instance /etc/init.d/dibbler . With systemd, you have to make a &lt;strong&gt;service&lt;/strong&gt; file in &lt;strong&gt;/etc/systemd/system/&lt;/strong&gt; .&lt;/p&gt;&lt;p&gt;Make the following file&amp;#160;: &lt;strong&gt;/etc/systemd/system/dibbler.service&lt;/strong&gt;&amp;#160;:&lt;/p&gt;&lt;pre&gt;[Unit]
Description=Dibbler
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/sbin/dibbler-client start
ExecStop=/usr/local/sbin/dibbler-client stop
PrivateTmp=true
NonBlocking=yes

[Install]
WantedBy=multi-user.target&lt;/pre&gt;&lt;p&gt;Run the following command to make systemd read file&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl daemon-reload&lt;/pre&gt;&lt;p&gt;Enable the service&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl enable dibbler.service&lt;/pre&gt;&lt;p&gt;And then, try to start it&amp;#160;:&lt;/p&gt;&lt;pre&gt;systemctl start dibbler.service&lt;/pre&gt;&lt;p&gt;Check everything is fine&amp;#160;:&lt;/p&gt;&lt;pre&gt;service dibbler status
ifconfig
route -6
ping6 whatever-you-want.com&lt;/pre&gt;&lt;p&gt;Reboot and the IPv6 networking should work at startup&amp;#160;! &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;&lt;p&gt;Addendum&amp;#160;: just in case, don&amp;#8217;t use resolvconf with IPv6 DNS pushing and if possible keep IPv4 DNS, it would be such a pity if the IPv6 networking crashes while your DNS servers are set to IPv6 addresses (yeah, it happened to to me)&amp;#8230;&lt;/p&gt;&lt;h3&gt;Sources&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://documentation.online.net/en/serveur-dedie/reseau/ipv6-prefix&quot;&gt;http://documentation.online.net/en/serveur-dedie/reseau/ipv6-prefix&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.lowendtalk.com/discussion/48591/configuring-ipv6-for-proxmox-kvm-on-dedibox-online-net&quot;&gt;http://www.lowendtalk.com/discussion/48591/configuring-ipv6-for-proxmox-kvm-on-dedibox-online-net&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd&quot;&gt;http://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://sulek.fr/index.php?article60/configuration-ipv6-pour-une-dedibox-sous-centos-7&quot;&gt;https://sulek.fr/index.php?article60/configuration-ipv6-pour-une-dedibox-sous-centos-7&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&quot;&gt;http://www.mattb.net.nz/blog/2011/05/12/linux-ignores-ipv6-router-advertisements-when-forwarding-is-enabled/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&quot;&gt;https://forum.online.net/index.php?/topic/5380-configuring-ipv6-in-proxmox-on-dedibox-from-onlinenet/&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>About ToBeHost : the last of my student's projects</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/09/24/About-ToBeHost-%3A-the-last-of-my-student-s-projects</link>
        <guid isPermaLink="false">urn:md5:1e13d19d1de92f79d00916da194c7137</guid>
        <pubDate>Thu, 01 Oct 2015 23:55:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>My Life</category>
                          <category>debian</category>
                  <category>drupal</category>
                  <category>hack</category>
                  <category>puppet</category>
                  <category>serie-hosting-panel-drupal-puppet</category>
                  <category>tobehost</category>
                  <category>vhffs</category>
                <description>&lt;p&gt;Hello there, this is not your ordinary reading on this blog. This post is a sort of introduction for a series of posts about the making of a free web hosting provider, implementing a web panel from scratch using &lt;a href=&quot;https://www.drupal.org/&quot;&gt;Drupal&lt;/a&gt; for front-end and &lt;a href=&quot;https://puppetlabs.com/&quot;&gt;Puppet&lt;/a&gt; as back-end.&lt;/p&gt;&lt;p&gt;But first, let me introduce you the reason why we started the project. I said &amp;#8220;we&amp;#8221; because I am not the only one in the boat, but it&amp;#8217;s me who will make all the technical choices, and implement it. I am also the one who was saying &amp;#8220;give up&amp;#8221; to my colleague a few months ago, before going back with this new and exciting crazy idea.&lt;/p&gt;          &lt;h3&gt;Genesis&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;http://www.tobehost.net/&quot;&gt;ToBeHost&lt;/a&gt; is a project we started around 2008~2009. Before that, I was an active member at a free hosting provider (&amp;#8220;Chez Mémé .net&amp;#8221;). When this hosting provider closed, due to the lack of time from its founders, me and a friend I met on this hosting provider stated that we had both the technical and time resources to make our own hosting provider. It was just loaning a dedicated server and configuring all the stuff you need to have your site working. We were not experts (yet), but be were confident in the fact that we had the capacities to learn, and to make it working. This is also the moment where I started &lt;a href=&quot;http://www.catb.org/esr/faqs/hacker-howto.html&quot;&gt;hacking&lt;/a&gt; on GNU/Linux&lt;/p&gt;&lt;p&gt;We tried several web panels. Between love and hate, we finally choose &lt;a href=&quot;http://www.vhffs.org&quot;&gt;VHFFS&lt;/a&gt;. VHFFS is a great piece of software. For the kiddie I was, it was the sort of &amp;#8220;perfect-even-scary&amp;#8221; piece of Linux engineering. Because mass web hosting involves dealing with a lot of &amp;#8220;subsystems&amp;#8221; to make it work, what VHFFS was doing was simply amazing to me. Using &lt;em&gt;libnss&lt;/em&gt; and &lt;em&gt;nscd&lt;/em&gt; to make system user from a database was for me the cleverest way to make system users without having to deal with system commands. Using unix permissions and system users and groups instead of hacky chroots, safe_mode, and open_basedir was definitely feeling right to me. I learned a lot about Linux and Debian, and my first (and actually unique) &lt;a href=&quot;http://listengine.tuxfamily.org/vhffs.org/vhffs-dev/2011/07/msg00025.html&quot;&gt;contributed patch&lt;/a&gt; made me feel so proud of me.&lt;/p&gt;&lt;h3&gt;The long love (and hate) story&lt;/h3&gt;&lt;p&gt;Dealing with a single server, on a student time, was not complicated. When something went wrong, I was looking for the answer by myself because I was (and I am still) afraid of what people can think or say to me on a public IRC channel. We had some downtimes, and a few fears while restoring backups, but things were globally going well.&lt;/p&gt;&lt;p&gt;Some things were a little bit cumbersome, but I was thinking that it was part of the job. Re-compiling PureFTPD ans MySQL package at each upgrade was not actually a problem, because I was eager to learn how to patch, compile, and hack into Debian. I even &lt;a href=&quot;http://uname.pingveno.net/wiki/wiki.php/Vhffs_Nss&quot;&gt;rewrote the SQL queries when we upgraded to Debian Lenny&lt;/a&gt;, which was using libnss2.&lt;/p&gt;&lt;p&gt;The years passed, I was growing and becoming older (hey, don&amp;#8217;t laugh). My years at university was taking much and much time over my &amp;#8220;internet time&amp;#8221;, as I was getting involved in the students&amp;#8217; association and my final exams were approaching. Finally, the project was in an informal standby, we decided that we had to close it, because we were both very busy elsewhere.&lt;/p&gt;&lt;p&gt;We officially closed. We sent the mail to users, I was ready to backup my configuration files and delete the data. We didn&amp;#8217;t do it. Because of our sloppy feelings, and the fact that &amp;#8220;it worked&amp;#8221;, without &amp;#8220;touching anything&amp;#8221;. It was such a pity to let it go.&lt;/p&gt;&lt;h3&gt;The last breath (or not)&lt;/h3&gt;&lt;p&gt;Some months ago, we realized it had been several years that the project was officially dead. I didn&amp;#8217;t stop hacking Linux. I had left my full-time job because I was working too much on projects I didn&amp;#8217;t like (&lt;a class=&quot;ref-post&quot; href=&quot;https://uname.pingveno.net/blog/index.php/post/2013/02/01/Pourquoi-j-ai-chang%C3%A9-de-job&quot;&gt;and some other reasons&lt;/a&gt;), and was running a freelance activity. My colleague was running &lt;a href=&quot;http://hawaii.do/&quot;&gt;a successful IT company&lt;/a&gt; with his associates, and we were working together on some professional projects (we still are).&lt;/p&gt;&lt;p&gt;New tools and software have appeared since my last glance to ToBeHost, and I also learned how to use new tools. I asked my colleague to let the project go, but we finally paid another month for the server.&lt;/p&gt;&lt;p&gt;And then, I thought: web hosting is actually what I am into at that time. I know how to do it the right way, with the smallest administration effort. None of the alternative panels was fitting as well as VHFFS for the work we wanted. Let&amp;#8217;s take all the VHFFS goods (strictly unix permissions, not be afraid of user access to shell, trust user isolation and quota), and add some bullshit (PHP panel, made on top of a CMS), with a little bit of magic (Puppet automation). Let&amp;#8217;s put it together, and see what is coming from it.&lt;/p&gt;&lt;p&gt;Voilà. This is how this project started.&lt;/p&gt;&lt;h3&gt;Addendum&lt;/h3&gt;&lt;p&gt;The project started, and it is pratically ready for beta-test. I will try to write that series of posts and explain how we made it, in order to inspire other people, and to help me keep my ideas clear.&lt;/p&gt;&lt;p&gt;As you may think, it is and it will be &lt;strong&gt;highly experimental&lt;/strong&gt;. I don&amp;#8217;t know if the growing of Puppet objects will be sustainable in the long term. I don&amp;#8217;t know if Drupal will drive me crazy to the point I would rage delete my code. I don&amp;#8217;t know if the whole project will be clean enough to release it opensource. But we will &lt;strong&gt;try&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.tobehost.net/nous-contacter/&quot;&gt;Wanna join&lt;/a&gt;&amp;#160;?&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Postfix : configure postmaster, hostmaster, and abuse catchall  for RFC compliance</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/08/29/Postfix-%3A-configure-postmaster%2C-hostmaster%2C-and-abuse-catchall-for-RFC-compliance</link>
        <guid isPermaLink="false">urn:md5:2236b92a9adc8066108e9709c6c32959</guid>
        <pubDate>Sat, 29 Aug 2015 18:02:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>catchall</category>
                  <category>debian</category>
                  <category>mail</category>
                  <category>postfix</category>
                  <category>server</category>
                <description>          &lt;p&gt;This short howto will show you how to set up a catchall for common required email addresses. Some mail servers are testing if mail is accepted on this addresses to detect spammymail servers. Hostmaster address can also be used for domain Trading, to check the ownership of the domain.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;1. &lt;/strong&gt;Create a file named &lt;strong&gt;/etc/postfix/regexp-catchall.cf&lt;/strong&gt; with the following content:&lt;/p&gt;&lt;pre&gt;# Catchall to comply with RFC standards
/^postmaster@/    youshouldreadit@mydomain.com
/^hostmaster@/    youshouldreadit@mydomain.com
/^abuse@/         youshouldreadit@mydomain.com&lt;/pre&gt;&lt;p&gt;Replace &lt;em&gt;youshouldreadit@mydomain.com&lt;/em&gt; with a mail address you actually read.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Open &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; and locate (or create) the line &lt;strong&gt;virtual_alias_maps&lt;/strong&gt;, and add at the end &lt;strong&gt;regexp:/etc/postfix/regexp-catchall.cf&lt;/strong&gt;, for instance:&lt;/p&gt;&lt;pre&gt;virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, regexp:/etc/postfix/regexp-catchall.cf&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;3. &lt;/strong&gt;Restart Postfix.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Warning&amp;#160;: read &lt;a href=&quot;http://uname.pingveno.net/blog/index.php/post/2015/08/29/Postfix-%3A-configure-postmaster%2C-hostmaster%2C-and-abuse-catchall-for-RFC-compliance#c73895&quot;&gt;comment #4&lt;/a&gt; for issues with this setup&lt;/strong&gt;.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Linux : déterminer la taille réelle d'un fichier creux</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/06/10/Linux-%3A-d%C3%A9terminer-la-taille-r%C3%A9elle-d-un-fichier-creux</link>
        <guid isPermaLink="false">urn:md5:044b24e2163e37313e414a27cf2a68c6</guid>
        <pubDate>Wed, 10 Jun 2015 18:12:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>du</category>
                  <category>fichier creux</category>
                  <category>linux</category>
                  <category>ls</category>
                  <category>taille</category>
                <description>          &lt;p&gt;Pour référence, et parce que c&amp;#8217;est parfois utile de connaître la taille réelle d&amp;#8217;un fichier creux.&lt;/p&gt;

&lt;p&gt;Pour afficher la taille déclarée&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
$ &lt;strong&gt;ls -lh nomdufichier&lt;/strong&gt;
-rw-r--r-- 1 root root &lt;strong&gt;401G&lt;/strong&gt; Jun 10 18:09 nomdufichier&lt;/pre&gt;

&lt;p&gt;Pour afficher la taille réelle&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
$ &lt;strong&gt;du -h nomdufichier&lt;/strong&gt;
&lt;strong&gt;60G&lt;/strong&gt;    nomdufichier&lt;/pre&gt;

&lt;p&gt;&lt;em&gt;Rappel&amp;#160;: un fichier creux est un fichier dont la taille déclarée pour le système est différente de la taille effective sur le disque. C&amp;#8217;est particulièrement utile pour créer des fichiers à écriture aléatoire (par exemple des fichiers téléchargés par P2P), ou des disques de machines virtuelles (qcow2, vmdk).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Un fichier creux s&amp;#8217;obtient en déclarant un index de fin de fichier plus grand que la taille effectivement &amp;#8220;remplie&amp;#8221; par le fichier sur le disque.&lt;/em&gt;&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Configurer un backup incrémental avec duplicity, rsync, et backupninja sous Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/02/21/Configurer-un-backup-incr%C3%A9mental-avec-duplicity%2C-rsync%2C-et-backupninja-sous-Debian</link>
        <guid isPermaLink="false">urn:md5:53eb9484898eb5bb3e1f00820c261548</guid>
        <pubDate>Tue, 09 Jun 2015 14:37:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>backup</category>
                  <category>backupninja</category>
                  <category>debian</category>
                  <category>serveur</category>
                <description>&lt;p&gt;&lt;a class=&quot;ref-post&quot; href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/02/17/Set-up-files-and-database-incremental-backup-with-duplicity%2C-rsync%2C-and-backupninja-on-Debian&quot;&gt;English version&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Introduction&lt;/h3&gt;

&lt;p&gt;Si vous savez ce qu'est un backup, vous devriez savoir qu'il y a plusieurs types de backups :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Un backup complet copie tous les fichiers, en espérant que votre disque de backup soit assez grand pour accueillir plus d'un backup.&lt;/li&gt;
	&lt;li&gt;Un backup incrémental commence par faire un backup complet, puis les fois suivantes n'enregistre que les &quot;différences&quot; sur les fichiers modifiés.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Évidemment, un backup complet est plus simple à restaurer, puisque ce sont les fichiers, et rien que les fichiers ; alors que le backup incrémental a un format de fichier spécial lui permettant de représenter les &quot;diffs&quot; à chaque sauvegarde. Mais considérant le gain d'un backup incrémental en bande passante, vitesse, et espace disque , votre solution pour un backup régulier devrait être le backup incrémental.&lt;/p&gt;

&lt;h3&gt;Les outils&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Duplicity&lt;/strong&gt; est un logiciel libre similaire à rdiff-backup. Duplicity permet de créer un backup incrémental. Duplicity peut également chiffrer les fichiers, pour pouvoir les envoyer en toute sécurité sur un service de stockage distant. Dans une configuration classique, Duplicity est utilisé conjointement avec rsyc pour optimiser les temps de transfert vers le stockage distant, mais vous pouvez très bien utiliser un disque de stockage local, un serveur FTP, ou un cloud Amazon E3 pour y envoyer vos sauvegardes. Comme le titre l'indique, dans cet exemple j'utiliserai rsync.&lt;/p&gt;

&lt;p&gt;Et les bases de données ? Les bases de données ne peuvent pas être sauvegardées simplement en copiant les fichiers de données, car cela peut provoquer une corruptio&amp;nbsp; de données, et vous aurez des bases inutilisables dans vos sauvegardes. Il nous faudrait donc un script qui dump toutes les bases de données avant de sauvegarder ces fichiers de dump via notre méthode de sauvegarde préférée.&lt;/p&gt;

&lt;p&gt;Bonne nouvelle : &lt;strong&gt;backupninja&lt;/strong&gt; sait faire tout cela. Backupninja est une sorte de &quot;backup-master&quot; : il est capable de récupérer des données depuis différentes sources (fichiers, bases de données...) et les envoyer à différentes destinations (backup simple, duplicity...), il suffit juste d'écrire les fichiers de configuration correspondants !&lt;/p&gt;

&lt;p&gt;Dans cet exemple, nous utiliserons donc backupninja pour récupérer nos fichiers et nos bases de données, et les envoyer pour un backup incrémental Duplicity, stocké sur un serveur SSH distant, en utilisant rsync.&lt;/p&gt;

&lt;p&gt;C'est parti !&lt;/p&gt;          &lt;h3&gt;Pré-requis&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;Une machine sous Debian que nous allons backuper, appelons-la &lt;strong&gt;production&lt;/strong&gt;

	&lt;ul&gt;
		&lt;li&gt;Un serveur de backup avec accès SSH (SSH est requis pour rsync mais vous pourriez avoir un simple serveur FTP), appelons-la &lt;strong&gt;backup&lt;/strong&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Savoir modifier des fichiers de configuration et relancer un service&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Configurez le compte sur le serveur de backup&lt;/h3&gt;

&lt;p&gt;Pour pouvoir envoyer les sauvegardes vers le serveur &lt;strong&gt;backup&lt;/strong&gt; via rsync, nous avons besoin de nous identifier sur ce serveur à partir de &lt;strong&gt;production&lt;/strong&gt; sans spécifier de mot de passe.&lt;/p&gt;

&lt;p&gt;Tout d'abord, travaillons en root sur &lt;strong&gt;production&lt;/strong&gt; : &lt;code&gt;sudo -s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Créez les clef SSH pour root : &lt;code&gt;ssh-keygen -t rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Après avoir tapé la commande précédente, la clef publique va s'installer dans &lt;code&gt;/root/.ssh/id_rsa.pub&lt;/code&gt; et la clef privée dans &lt;code&gt;/root/.ssh/id_rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;À présent, considérons &lt;strong&gt;backup&lt;/strong&gt;, vérifiez que votre serveur SSH sur &lt;strong&gt;backup&lt;/strong&gt; accepte l'authentification par clefs privées. Dans le fichier &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;, les lignes suivantes doivent apparaître (non commentées) :&lt;/p&gt;

&lt;pre&gt;
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     %h/.ssh/authorized_keys&lt;/pre&gt;

&lt;p&gt;Sinon, ajoutez-les et relancez le service ssh.&lt;/p&gt;

&lt;p&gt;Maintenant, ajoutez l'utilisateur prod_server sur &lt;strong&gt;backup&lt;/strong&gt; : &lt;code&gt;useradd prod_server&lt;/code&gt;&lt;br /&gt;
Vous pourriez avoir envie changer son dossier home, je suppose que vous savez comment le faire.&lt;/p&gt;

&lt;p&gt;Retour sur &lt;strong&gt;production&lt;/strong&gt;, copiez la clef publique dans le fichier /home/prod_server/.ssh/authorized_keys de &lt;strong&gt;backup&lt;/strong&gt;.&lt;br /&gt;
La méthode bourrin : &lt;code&gt;scp /root/.ssh/id_rsa.pub root@backup:/home/prod_server/.ssh/authorized_keys&lt;/code&gt;&lt;br /&gt;
La méthode gentlemen : copiez-collez le contenu de &lt;code&gt;&lt;strong&gt;production:&lt;/strong&gt;/root/.ssh/id_rsa.pub&lt;/code&gt; à la fin du fichier &lt;code&gt;&lt;strong&gt;backup:&lt;/strong&gt;/home/prod_server/.ssh/authorized_keys&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Si vous avez tout fait correctement, vous devriez pouvoir vous connecter en ssh depuis votre compte root de &lt;strong&gt;production&lt;/strong&gt; sur le compte prod_server de &lt;strong&gt;backup&lt;/strong&gt; sans spécifier de mot de passe.&lt;/p&gt;

&lt;h3&gt;Installez backninja (et ses amis)&lt;/h3&gt;

&lt;p&gt;Sur &lt;strong&gt;production&lt;/strong&gt;, entrez la commande : &lt;code&gt;sudo apt-get install backupninja duplicity rsync&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Configurez le dump des bases de données&lt;/h3&gt;

&lt;p&gt;C'est parti, configurons &lt;strong&gt;backupninja&lt;/strong&gt; !&lt;/p&gt;

&lt;p&gt;Pour MySQL, copiez le fichier d'exemple à partir de &lt;code&gt;/usr/share/doc/backupninja/examples/example.mysql&lt;/code&gt; dans le dossier &lt;code&gt;/etc/backup.d/10-alldb.mysql&lt;/code&gt; et modifiez-le pour vos propres besoins (le fichier est simple et bien commenté).&lt;/p&gt;

&lt;pre&gt;
databases   = all
backupdir   = /var/backups/mysql
hotcopy     = no
sqldump     = yes
compress    = yes
configfile = /etc/mysql/debian.cnf&lt;/pre&gt;

&lt;p&gt;Pour PostgreSQL, même chose ! Copiez le fichier &lt;code&gt;/usr/share/doc/backupninja/examples/example.mysql&lt;/code&gt; dans le dossier &lt;code&gt;/etc/backup.d/10-alldb.pgsql&lt;/code&gt; et modifiez les valeurs souhaitées.&lt;/p&gt;

&lt;pre&gt;
backupdir = /var/backups/postgres
databases = all
compress = yes
format = plain&lt;/pre&gt;

&lt;p&gt;Pourquoi est-ce que j'utilise le préfixe &lt;code&gt;10-&lt;/code&gt; au début de mes fichiers ? Pour la même raison pour laquelle vous préfixez vos fichiers de configuration Nginx : pour gérer l'ordre de lecture. J'ai besoin de créer les dumps des bases de données avant de créer le backup des fichiers, sinon Duplicity enregistrera les fichiers de la veille, et les fichiers que nous venons de créer devront attendre le lendemain pour être sauvegardés ! Donc, les fichiers de configuration qui vont créer les dumps seront préfixé par &lt;code&gt;10- &lt;/code&gt;et les fichiers pour configurer le backup incrémental de Duplicity seront préfixés par &lt;code&gt;20-, par exemple&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Les dumps SQL seront stockés dans &lt;code&gt;/var/backups/&lt;/code&gt; selon ma configuration actuelle.&lt;/p&gt;

&lt;h3&gt;Configuration de Duplicity pour le backup incrémental&lt;/h3&gt;

&lt;p&gt;Comme tout à l'heure, copiez le fichier d'exemple : &lt;code&gt;cp /usr/share/doc/backupninja/examples/example.dup &lt;/code&gt;&lt;code&gt;/etc/backup.d/20-files.dup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Et modifiez les valeurs, en particulier la valeur desturl :&lt;/p&gt;

&lt;pre&gt;
# Disable testconnect because we use desturl
testconnect = no

# You may change this if you are a partition-maniac
tmpdir = /tmp

[gpg]
# Using symetric encryption for archive files
# Note that an encryption method is mandaory, either with symetric or private keys
# Don't forget to note that password somewhere !
password = whateveryouwant

[source]
# Specify the paths to your files
include = /var/spool/cron/crontabs
include = /var/log
include = /var/mail
include = /var/www
include = /etc
include = /root
include = /home
include = /usr/local

# And to your database dumps !
include = /var/backups/mysql
include = /var/backups/postgresql

# There are some files we don't need
# Don't forget to add the tmpdir in the exclude list, if it was included in the previous paths !
exclude = /home/*/.gnupg
exclude = /var/cache/backupninja/duplicity
exclude = /tmp

[dest]
# Adjust these to your own taste
incremental = yes
increments = 15
keep = 30
keepincroffulls = all

# Specify the backup server crendentials
## desturl = file:///usr/local/backup
## desturl = rsync://user@other.host//var/backup/bla
## desturl = s3+http://
## desturl = ftp://myftpuser@ftp.example.org/remote/ftp/path
&lt;strong&gt;desturl = rsync://prod_server@backup//home/prod_server/data&lt;/strong&gt;

# Only if you choose FTP
# ftp_password = whateveryouwant&lt;/pre&gt;

&lt;p&gt;Cette configuration utilise un chiffrement symétrique pour les archives sauvegardées. Si vous voulez mettre en place un chiffrement asymétrique, vous pouvez &lt;a href=&quot;https://wiki.debian.org/Duplicity&quot;&gt;lire la documentation&lt;/a&gt; et adapter la configuration.&lt;/p&gt;

&lt;h3&gt;Configurez la fréquence des backups&lt;/h3&gt;

&lt;p&gt;Vous avez peut-être remarqué que backupninja a créé un cronjob dans &lt;code&gt;/etc/cron.d/backupninja&lt;/code&gt; mais si vous ouvrez ce fichier, vous constaterez que le cronjob est lancé toutes les heures. Pourquoi ? Parce que le cronjob n'est utilisé que pour lancer le backup, qui vérifie si une mise à jour du backup est nécessaire avant de lancer réellement l'opération de backup. Pour modifier les heures et la fréquence des mises à jour, vous pouvez modifier le fichier &lt;code&gt;/etc/backupninja.conf&lt;/code&gt; :&lt;/p&gt;

&lt;pre&gt;
when = everyday at 01:00&lt;/pre&gt;

&lt;p&gt;Ajustez la valeur selon vos souhaits. Vous pouvez combiner plusieurs lignes, si vous voulez plusieurs dates de démarrage (&lt;a href=&quot;https://labs.riseup.net/code/issues/577&quot; hreflang=&quot;en&quot;&gt;en savoir plus&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;Démarrez votre backup, et vérifiez son bon fonctionnement&lt;/h3&gt;

&lt;p&gt;C'est le moment de démarrer votre backup pour la première fois ! Si vous ne voulez pas attendre une heure pour que le cron se lance, vous pouvez lancer le backup immédiatement avec la commande &lt;code&gt;backupninja -d -n&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Si aucune erreur ne s'affiche pendant l'exécution, bravo ! Vous venez de configurer backupninja avec succès !&lt;/p&gt;

&lt;p&gt;À présent, contrôlons que notre backup est bien arrivé : connectez-vous à &lt;strong&gt;backup&lt;/strong&gt; et listez le fichiers dans le dossier &lt;code&gt;/home/prod_server/data/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Vous devriez voir les fichiers d'index créés par Duplicity, vous ne pouvez pas les ouvrir sans utiliser quelques commandes :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Afficher le statut des &quot;collections&quot; : &lt;strong&gt;duplicity collection-status file:///home/prod_server/data&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Lister les fichiers dans l'archive : &lt;strong&gt;duplicity list-current-files file:///home/prod_server/data&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Restaurer le dernier backup dans un dossier précis &lt;strong&gt;duplicity restore file:///home/prod_server/data/ /home/prod_server/test-restore/&lt;/strong&gt; (si vous ne voyez des erreurs mais que les fichiers sont bien présents à la fin de l'exécution de la commande, c'est parce que Duplicity essaye de restaurer les atributs &quot;prorpiétaire&quot; des fichiers, et qu'il ne peut pas le faire si vous n'avez pas lancé la commande en root).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vous devez avoir le programme Duplicity installé sur le serveur &lt;strong&gt;backup&lt;/strong&gt;&amp;nbsp; pour pouvoir utiliser ces commandes en mode shel sur &lt;strong&gt;backup&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Vous pouvez aussi lancer ces commandes sur le serveur &lt;strong&gt;production&lt;/strong&gt; et accéder aux backups stockés sur &lt;strong&gt;backup&lt;/strong&gt; en utilisant la &lt;em&gt;desturl&lt;/em&gt; que vous avez configurée au lieu du préfixe&amp;nbsp;&lt;code&gt;file://&lt;/code&gt; que vous utilisez quand vous lancez la commande sur &lt;strong&gt;backup&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Vous devriez maintenant être capables d'implémenter une solution complète de backup en utilisant backupninja.&lt;/p&gt;

&lt;p&gt;J'espère que cet article vous a été utile, vous pouvez rédiger un commentaire via le formulaire ci-dessous si vous rencontrez des problèmes avec cette documentation.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Nagios : quick and dirty patch to enable (force) SSL on check_mysql_health</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/06/06/Nagios-%3A-quick-and-dirty-patch-to-enable-%28force%29-SSL-on-check_mysql_health</link>
        <guid isPermaLink="false">urn:md5:3244ad7656fe67739208c0268a811102</guid>
        <pubDate>Sat, 06 Jun 2015 16:10:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>check_mysql_health</category>
                  <category>debian</category>
                  <category>monitoring</category>
                  <category>mysql</category>
                  <category>nagios</category>
                  <category>server</category>
                <description>          &lt;p&gt;Sometimes you don&amp;#8217;t want to set up a VPN just to safely monitor your MySQL servers. Because SSL should be implemented in &lt;a href=&quot;https://exchange.nagios.org/directory/MySQL/check_mysql_health/details&quot;&gt;check_mysql_health&lt;/a&gt;, here is a quick and dirty patch for SSL connexion. I assume you already configured your MySQL server to use SSL if client wants to (or if user requires ssl).&lt;/p&gt;

&lt;p&gt;File &lt;strong&gt;/usr/lib/nagios/plugins/check_mysql_health&lt;/strong&gt; at line &lt;strong&gt;1863&lt;/strong&gt;, after the following block&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
    } else {
      $self-&amp;gt;{dsn} .= sprintf &quot;;host=%s&quot;, $self-&amp;gt;{hostname};
      $self-&amp;gt;{dsn} .= sprintf &quot;;port=%s&quot;, $self-&amp;gt;{port}
          unless $self-&amp;gt;{socket} || $self-&amp;gt;{hostname} eq 'localhost';
      $self-&amp;gt;{dsn} .= sprintf &quot;;mysql_socket=%s&quot;, $self-&amp;gt;{socket}
          if $self-&amp;gt;{socket};&lt;/pre&gt;

&lt;p&gt;Add these lines&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
    $self-&amp;gt;{dsn} .= &quot;;mysql_ssl=1&quot;;
    $self-&amp;gt;{dsn} .= &quot;;mysql_ssl_client_key=/etc/ssl/mysql/client.key&quot;;
    $self-&amp;gt;{dsn} .= &quot;;mysql_ssl_client_cert=/etc/ssl/mysql/client.crt&quot;;
    $self-&amp;gt;{dsn} .= &quot;;mysql_ssl_ca_file=/etc/ssl/mysql/ca.crt&quot;;&lt;/pre&gt;

&lt;p&gt;Where &lt;strong&gt;/etc/ssl/mysql/client.key&lt;/strong&gt; is the path to client key, &lt;strong&gt;/etc/ssl/mysql/client.crt&lt;/strong&gt; the path to client certificate, and &lt;strong&gt;/etc/ssl/mysql/ca.crt&lt;/strong&gt; the path to the CA certificate.&lt;/p&gt;

&lt;p&gt;It should work, while there is still no &amp;#8220;SSL switch&amp;#8221; on that plugin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;&amp;#160;: actually there is an undocumented param named &amp;#8220;&amp;#8212;mycnf&amp;#8221; which should allow you to enable SSL for client connection in a prettier way.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Migrate an OpenVPN configuration to Debian 8 (Jessie) with systemd</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/05/23/Migrate-an-OpenVPN-configuration-to-Debian-8-%28Jessie%29-with-systemd</link>
        <guid isPermaLink="false">urn:md5:a60d9b9041f53247753bbe51ac24a8c0</guid>
        <pubDate>Sat, 23 May 2015 10:32:00 +0200</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>jessie</category>
                  <category>openvpn</category>
                  <category>systemd</category>
                <description>          &lt;p&gt;This article could have been avoided if the Debian documentation was up-to-date. Actually it is not, and the solution came from Fedora documentation for OpenVPN.&lt;/p&gt;

&lt;p&gt;Debian 8 uses systemd by default, and it implies several changes, in&amp;nbsp; particular the way you start/stop your services.&lt;/p&gt;

&lt;h3&gt;The main topic : systemd&lt;/h3&gt;

&lt;h4&gt;What changes&lt;/h4&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;p&gt;A new fancy command now manage the startup : &lt;strong&gt;systemctl&lt;/strong&gt; (don't mess with the &lt;strong&gt;sysctl&lt;/strong&gt; command used for network configuration !)&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;The startup dependencies are no longer in the LSB headers in startup scripts (way too simple, boy), the dependencies are stored as symlinks in subdirectories located in &lt;strong&gt;/etc/systemd/*&lt;/strong&gt; . Note that &lt;strong&gt;/etc/systemd/&lt;/strong&gt; contains some static configuration files, and that the real services configuration files are stored in &lt;strong&gt;/lib/systemd/*&lt;/strong&gt; (this is where the symlinks from &lt;strong&gt;/etc/systemd/*&lt;/strong&gt; points to).&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;Some services have been split from monolithic startup to dynamic&lt;/strong&gt;. It means that you potentially have to enable and run multiple &quot;services&quot; in order to actually start the full &quot;service&quot;. For instance, &lt;strong&gt;OpenVPN no longer runs every available configuration in /etc/openvpn/*.conf , you have to explicitely activate each *.conf file as a service in systemd !&lt;/strong&gt;&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;What doesn't change&lt;/h4&gt;

&lt;ul&gt;
	&lt;li&gt;
	&lt;p&gt;You can still start your services with &lt;strong&gt;service &lt;em&gt;servicename&lt;/em&gt; start&lt;/strong&gt;.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;The init scripts in &lt;strong&gt;/etc/init.d/*&lt;/strong&gt; still exists, and some are still usable (monolithics services).&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Run your OpenVPN configuration&lt;/h3&gt;

&lt;p&gt;While you can still use the command &lt;strong&gt;openvpn --config /etc/openvpn/yourconfigfile.conf&lt;/strong&gt;, you should do it with systemd. If your configuration file is /etc/openvpn/sample.conf, you should start your VPN connexion with &lt;strong&gt;systemctl start openvpn@sample.service&lt;/strong&gt; .&lt;/p&gt;

&lt;p&gt;Note that &lt;strong&gt;service openvpn@sample start&lt;/strong&gt; also works.&lt;/p&gt;

&lt;h3&gt;Start your VPN at boot&lt;/h3&gt;

&lt;p&gt;Again, the auto startup was too simple. You now have to enable every *.conf file at boot. Enable you newly sample.conf at startup with the command &lt;strong&gt;systemctl enable openvpn@sample.service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This actually creates a symlink in &lt;strong&gt;/etc/systemd/system/multi-user.target.wants/openvpn@sample.service&lt;/strong&gt; pointing to &lt;strong&gt;/lib/systemd/system/openvpn@.service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ok, it's simpler for dynamic loads, but who needs to dynamically enable and disable configuration at boot ? If I want a different configuration, I simply write different files in the right folder...&lt;/p&gt;

&lt;h3&gt;Meanwhile, in Debian Apache package&lt;/h3&gt;

&lt;p&gt;You can enable and disable VirtualHosts by using the /etc/apache2/sites-available/ and /etc/apache2/sites-enabled/ folders. No hidden features, no boot startup configuration, all configuration files in /etc/programname/ . Way too simple ?&lt;/p&gt;

&lt;p&gt;Hey, what if we had to configure a startup script for every VirtualHost ? Should be fun, don't you think ?&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Openvpn#Working_with_systemd&quot; hreflang=&quot;en&quot;&gt;OpenVPN : working with systemd [Fedora wiki]&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Systemd#How_do_I_start.2Fstop_or_enable.2Fdisable_services.3F&quot; hreflang=&quot;en&quot;&gt;Systemd : how to enable and start services [Fedora wiki]&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Configure sender rate limits to prevent spam, using cluebringer (policyd) with Postfix</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/03/11/Configure-sender-rate-limits-to-prevent-spam%2C-using-cluebringer-%28policyd%29-with-Postfix</link>
        <guid isPermaLink="false">urn:md5:11c6569b7382d3cd707a41e60deae65c</guid>
        <pubDate>Fri, 13 Mar 2015 09:18:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>cluebringer</category>
                  <category>debian</category>
                  <category>mail</category>
                  <category>policyd</category>
                  <category>postfix</category>
                  <category>server</category>
                <description>&lt;p&gt;This small how-to will show you how to configure cluebringer (aka policyd) to set a per-hour/per-user limit for sent mails. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;p&gt;This how-to is Debian-oriented but should apply to any unix operating system.&lt;/p&gt;          &lt;h3&gt;Requirements&lt;/h3&gt;

&lt;p&gt;A mail server with Postfix installed.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;Install a DBMS (MySQL for instance), cluebringer, and cluebringer-webui&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
apt-get install mysql-server cluebringer cluebringer-mysql cluebringer-webui&lt;/pre&gt;

&lt;p&gt;Note that cluebringer-webui will install apache as a dependency if you don&amp;#8217;t already have a webserver.&lt;/p&gt;

&lt;h3&gt;Set-up the Cluebringer database&lt;/h3&gt;

&lt;p&gt;Get the initial database schema that correspond to your DBMS, for instance mysql&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer/database/policyd-db.mysql.gz ~/ &amp;amp;&amp;amp; gunzip ~/policyd-db.mysql.gz&lt;/pre&gt;

&lt;p&gt;Create the database, and populate it with the initial dump&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# cd  ~/ &amp;amp;&amp;amp; mysql -u root -p
mysql&amp;gt; CREATE DATABASE cluebringer;
mysql&amp;gt; CREATE USER 'cluebringer'@'localhost' IDENTIFIED BY 'mypassword';
mysql&amp;gt; GRANT ALL PRIVILEGES ON cluebringer.* TO 'cluebringer'@'localhost';
mysql&amp;gt; \. policyd-db.mysql
mysql&amp;gt; quit
mysql&amp;gt; Bye
&lt;/pre&gt;

&lt;p&gt;Note that on Debian I had to modify the dump to make it work, &lt;em&gt;TYPE=InnoDB&lt;/em&gt; was rejected by MySQL as an invalid syntax.&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer&lt;/h3&gt;

&lt;p&gt;Add your DBMS credentials to the file &lt;strong&gt;/etc/cluebringer/cluebringer.conf&lt;/strong&gt;&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
DSN=DBI:mysql:dbname=cluebringer;host=localhost

DB_Type=mysql
DB_Host=localhost
DB_Port=3306
DB_Name=cluebringer
Username=cluebringer
Password=mypassword&lt;/pre&gt;

&lt;p&gt;And start it&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix-cluebringer start&lt;/pre&gt;

&lt;h3&gt;Configure Cluebringer webui&lt;/h3&gt;

&lt;p&gt;Configure the file &lt;strong&gt;/etc/cluebringer/cluebringer-webui.conf&lt;/strong&gt; with your DBMS credentials&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php

$DB_DSN=&quot;mysql:host=localhost;dbname=cluebringer&quot;;
$DB_USER=&quot;cluebringer&quot;;
$DB_PASS=&quot;mypassword&quot;;&lt;/pre&gt;

&lt;p&gt;Cluebringer Webui needs a web server to run. Copy the sample configuration from the package documentation&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
cp /usr/share/doc/postfix-cluebringer-webui/examples/httpd/cluebringer-httpd.conf /etc/apache2/conf.d/&lt;/pre&gt;

&lt;p&gt;Restart Apache&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service apache2 restart&lt;/pre&gt;

&lt;p&gt;You may need to adjust a few things to access it from the outside. If you a really lazy, just make a ssh tunnel to access the webserver from localhost&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
ssh -L 8008:localhost:80 mylogin@mymailserver&lt;/pre&gt;

&lt;p&gt;Don&amp;#8217;t forget&amp;#160;: you have to make this tunnel from the outside, do not run this command on server, it won&amp;#8217;t work.&lt;/p&gt;

&lt;p&gt;You should now be able to open http://localhost:8080/ and see your fresh new Cluebinger Webui&amp;#160;!&lt;/p&gt;

&lt;h3&gt;Configure Cluebringer using its webui&lt;/h3&gt;

&lt;h4&gt;Add a policy&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Policies&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Main&lt;/strong&gt;, disable Test policy (select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; and switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;yes&lt;/strong&gt;, validate)&lt;/p&gt;

&lt;p&gt;Add a new policy&amp;#160;: &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;, give it a name and a description&lt;/p&gt;

&lt;p&gt;Activate your new policy&amp;#160;: select policy and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt; (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Add a new member to your policy&amp;#160;: select it and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;. Specify &lt;strong&gt;any&lt;/strong&gt; as source and &lt;strong&gt;any&lt;/strong&gt; as destination.&lt;/p&gt;

&lt;p&gt;Go back to your policy, choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Members&lt;/strong&gt;, and the select your member, do &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Change&lt;/strong&gt;, and activate your new member (switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;).&lt;/p&gt;

&lt;h4&gt;Add a quota&lt;/h4&gt;

&lt;p&gt;Under &lt;strong&gt;Quotas&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Configure&lt;/strong&gt;, disable Test quotas.&lt;/p&gt;

&lt;p&gt;Add a new quota&amp;#160;: Choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Name&amp;#160;: whatever you want&lt;/li&gt;
	&lt;li&gt;Track&amp;#160;: &lt;strong&gt;user@domain&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Period (seconds)&amp;#160;: &lt;strong&gt;3600&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Link to policy&amp;#160;: specify the policy you created here&lt;/li&gt;
	&lt;li&gt;Verdict&amp;#160;: &lt;strong&gt;Defer&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Data&amp;#160;: set a custom error message here&lt;/li&gt;
	&lt;li&gt;Comment&amp;#160;: whatever you want&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your quota&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add a limit to your quota&amp;#160;: select your quota, and choose &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Limits&lt;/strong&gt;, then &lt;strong&gt;Action&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Add&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Type&amp;#160;: &lt;strong&gt;MessageCount&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Counter Limit&amp;#160;: &lt;strong&gt;200&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Activate your limit&amp;#160;: switch &lt;strong&gt;Disabled&lt;/strong&gt; to &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Configure Postfix to call Cluebringer for each mail sent&lt;/h3&gt;

&lt;p&gt;Open &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; and locate the line &lt;strong&gt;smtpd_sender_restrictions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Add &lt;strong&gt;check_policy_service inet:127.0.0.1:10031&lt;/strong&gt; at the end of the line, for instance&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf&lt;strong&gt;, check_policy_service inet:127.0.0.1:10031&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;If the line does not exists, simply add it.&lt;/p&gt;

&lt;p&gt;Don&amp;#8217;t forget to restart Postfix&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
service postfix restart&lt;/pre&gt;

&lt;h3&gt;Check your config&lt;/h3&gt;

&lt;p&gt;You can now send some mails to see what happens. To check if these mails are passed to Cluebringer, connect to MySQL as the cluebringer user&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
# mysql -u cluebringer -p cluebringer&lt;/pre&gt;

&lt;p&gt;And execute the query&amp;#160;:&lt;/p&gt;

&lt;pre&gt;
mysql&amp;gt; SELECT * FROM quotas_tracking;&lt;/pre&gt;

&lt;p&gt;You should see the value LastUpdate and Counter updating when sending a mail. Note that sending to multiple recipient will count like multiple mails were sent.&lt;/p&gt;

&lt;h3&gt;Pitfalls, bleeding edges, etc&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cluebringer versions prior to 2.1.x does not support IPv6&lt;/strong&gt;, your customers won&amp;#8217;t be able to send any mail if they have an IPv6 connection.&lt;/p&gt;

&lt;p&gt;Unfortunately, the Debian stable version (wheezy) provides Cluebringer 2.0.10 within its repositories, as well as the experimental release of Debian (sid). As an alternative, you should consider &lt;a href=&quot;http://wiki.policyd.org/download&quot;&gt;installing the 2.1.x experimental Cluebringer&lt;/a&gt; from official website instead of Debian packages from repositories.&lt;/p&gt;

&lt;h3&gt;References&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://wiki.policyd.org/installing&quot; hreflang=&quot;en&quot;&gt;Installing Policyd&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://imanudin.net/2014/09/09/zimbra-tips-how-to-configure-rate-limit-sending-message-on-policyd/&quot; hreflang=&quot;en&quot;&gt;Configuring Policyd for Zimbra&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://jrklein.com/2014/03/09/debian-wheezy-postfix-cluebringer-policyd-v2-ipv6/&quot; hreflang=&quot;en&quot;&gt;Debian, Cluebringer, IPv6&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Set up an incremental backup with duplicity, rsync, and backupninja on Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2015/02/17/Set-up-files-and-database-incremental-backup-with-duplicity%2C-rsync%2C-and-backupninja-on-Debian</link>
        <guid isPermaLink="false">urn:md5:d56ab4f920ea9aee3677e1e3916e5b89</guid>
        <pubDate>Fri, 20 Feb 2015 22:08:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>backup</category>
                  <category>backupninja</category>
                  <category>debian</category>
                  <category>server</category>
                <description>&lt;p&gt;&lt;a class=&quot;ref-post&quot; href=&quot;https://uname.pingveno.net/blog/index.php/post/2015/02/21/Configurer-un-backup-incr%C3%A9mental-avec-duplicity%2C-rsync%2C-et-backupninja-sous-Debian&quot;&gt;Version française&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is a not-so-concise how-to about setting up an incremental backup, using Backupninja with Duplicity backend on Debian.&lt;/p&gt;

&lt;h3&gt;Abstract&lt;/h3&gt;

&lt;p&gt;If you know what a backup is, you should know there are several types of backups :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;A full backup is when you just copy all your files, hoping that the hard drive on the backup server will not explode after 3 backups.&lt;/li&gt;
	&lt;li&gt;An incremental backup consist in a base full backup, and the next backups are just &quot;diffs&quot; sent to the backup server, to keep track of modified files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Obviously, a full backup is easier to read and to restore because it's just plain files, whereas an incremental backup has a specific file format to represent diffs. But considering the gain in speed, bandwidth, and disk space, your choice for a long-term backup solution should be the incremental backup.&lt;/p&gt;

&lt;h3&gt;The tools&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Duplicity&lt;/strong&gt; is an opensource software similar to rdiff-backup. It creates incremental backups. Duplicity can also encrypt your backups, so they can be safely sent to any remote disk provider. A classic setup for Duplicity would be using rsync as a backend to send files faster to the remote backup server, but you can also use a local drive, a remote FTP server, or an Amazon E3 cloud server. As the title says, I will be using rsync for that setup.&lt;/p&gt;

&lt;p&gt;But what about databases ? Databases can't be saved by simply copying files, it could lead to corrupted and unusable data in your backups, so you would use a backup script to fetch your databases before sending it to Duplicity.&lt;/p&gt;

&lt;p&gt;Good news : &lt;strong&gt;backupninja&lt;/strong&gt; is the global solution you need. Backupninja is a sort of &quot;backup-master&quot; : it can fetch different type of data (files, databases...) from different sources and sent it to different destinations (plain backup, duplicity, etc). you just have to write a specific config file for each source !&lt;/p&gt;

&lt;p&gt;We will use backupninja to fetch our databases, we will add these SQL archives to our files backup, send this to Duplicity backend, and finally send it to our backup server with rsync. And with just 3 config files (one by SQL type, one for Duplicity and rsync).&lt;/p&gt;

&lt;p&gt;Let's go !&lt;/p&gt;          &lt;h3&gt;Requirements&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;A Debian machine to backup, let's call it &lt;strong&gt;production&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;A backup server, with SSH access (SSH is required for rsync, but an FTP server can do the job), let's call it &lt;strong&gt;backup&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Configure the backup user on the remote machine&lt;/h3&gt;

&lt;p&gt;In order to send the backed up files to &lt;strong&gt;backup&lt;/strong&gt;, we will need a way to authenticate from &lt;strong&gt;production&lt;/strong&gt; without specifying a password.&lt;/p&gt;

&lt;p&gt;First, be root on &lt;strong&gt;production&lt;/strong&gt; : &lt;code&gt;sudo -s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, create ssh key pairs : &lt;code&gt;ssh-keygen -t rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The public key will set up on &lt;code&gt;/root/.ssh/id_rsa.pub&lt;/code&gt; and the private key in &lt;code&gt;/root/.ssh/id_rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, let's consider &lt;strong&gt;backup&lt;/strong&gt;, check if your SSH server on &lt;strong&gt;backup&lt;/strong&gt; acccepts the public key authentications. In &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;, you should have the lines :&lt;/p&gt;

&lt;pre&gt;
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     %h/.ssh/authorized_keys&lt;/pre&gt;

&lt;p&gt;If not, simply add it (and restart ssh service).&lt;/p&gt;

&lt;p&gt;Now, add the prod_server user on &lt;strong&gt;backup&lt;/strong&gt; : &lt;code&gt;useradd prod_server&lt;/code&gt;&lt;br /&gt;
You may want to change its home, I assume you know how to do it.&lt;/p&gt;

&lt;p&gt;Now, back to &lt;strong&gt;production&lt;/strong&gt;, simply copy the SSH public key to the &lt;strong&gt;backup&lt;/strong&gt; file named /home/prod_server/.ssh/authorized_keys&lt;br /&gt;
The trashy way : &lt;code&gt;scp /root/.ssh/id_rsa.pub root@backup:/home/prod_server/.ssh/authorized_keys&lt;/code&gt;&lt;br /&gt;
The classic way : copy/paste the content of &lt;code&gt;&lt;strong&gt;production:&lt;/strong&gt;/root/.ssh/id_rsa.pub&lt;/code&gt; at the end of the file &lt;code&gt;&lt;strong&gt;backup:&lt;/strong&gt;/home/prod_server/.ssh/authorized_keys&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you did it right, you should now be able to ssh from &lt;strong&gt;production&lt;/strong&gt; to &lt;strong&gt;backup&lt;/strong&gt; without password.&lt;/p&gt;

&lt;h3&gt;Install backupninja (and friends)&lt;/h3&gt;

&lt;p&gt;On &lt;strong&gt;production&lt;/strong&gt;, use the Debian magic line : &lt;code&gt;sudo apt-get install backupninja duplicity rsync&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Configure databases dump&lt;/h3&gt;

&lt;p&gt;Okay, let's start configuring &lt;strong&gt;backupninja&lt;/strong&gt; !&lt;/p&gt;

&lt;p&gt;For MySQL, copy the sample file from &lt;code&gt;/usr/share/doc/backupninja/examples/example.mysql&lt;/code&gt; to &lt;code&gt;/etc/backup.d/10-alldb.mysql&lt;/code&gt; and change it for your own needs (the file is pretty trivial and well commented).&lt;/p&gt;

&lt;pre&gt;
databases   = all
backupdir   = /var/backups/mysql
hotcopy     = no
sqldump     = yes
compress    = yes
configfile = /etc/mysql/debian.cnf&lt;/pre&gt;

&lt;p&gt;For PostgreSQL, all the same ! Copy &lt;code&gt;/usr/share/doc/backupninja/examples/example.mysql&lt;/code&gt; to &lt;code&gt;/etc/backup.d/10-alldb.pgsql&lt;/code&gt; and change the desired values.&lt;/p&gt;

&lt;pre&gt;
backupdir = /var/backups/postgres
databases = all
compress = yes
format = plain&lt;/pre&gt;

&lt;p&gt;Why am I using that weird &lt;code&gt;10- &lt;/code&gt;at the beginning of the file ? For the same reason you have to prefix your files with number in Nginx configuration : for precedence. I need the database dumps to be done just before the files backup, otherwise, backupninja will send to duplicity the dumps of yesterday, and next create new dumps without including it in the Duplicity files for the current backup ! So, my database backup configuration files have to be like &lt;code&gt;10- &lt;/code&gt;and my Duplicity configuration file should be like &lt;code&gt;20-, &lt;/code&gt;for instance.&lt;/p&gt;

&lt;p&gt;Note that the SQL dumps will be generated in &lt;code&gt;/var/backups/&lt;/code&gt; .&lt;/p&gt;

&lt;h3&gt;Configure Duplicity files backup&lt;/h3&gt;

&lt;p&gt;Again, copy the sample file : &lt;code&gt;cp /usr/share/doc/backupninja/examples/example.dup &lt;/code&gt;&lt;code&gt;/etc/backup.d/20-files.dup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And change its values :&lt;/p&gt;

&lt;pre&gt;
# Disable testconnect because we use desturl
testconnect = no

# You may change this if you are a partition-maniac
tmpdir = /tmp

[gpg]
# Using symetric encryption for archive files
# Note that an encryption method is mandaory, either with symetric or private keys
# Don't forget to note that password somewhere !
password = whateveryouwant

[source]
# Specify the paths to your files
include = /var/spool/cron/crontabs
include = /var/log
include = /var/mail
include = /var/www
include = /etc
include = /root
include = /home
include = /usr/local

# And to your database dumps !
include = /var/backups/mysql
include = /var/backups/postgresql

# There are some files we don't need
# Don't forget to add the tmpdir in the exclude list, if it was included in the previous paths !
exclude = /home/*/.gnupg
exclude = /var/cache/backupninja/duplicity
exclude = /tmp

[dest]
# Adjust these to your own taste
incremental = yes
increments = 15
keep = 30
keepincroffulls = all

# Specify the backup server crendentials
## desturl = file:///usr/local/backup
## desturl = rsync://user@other.host//var/backup/bla
## desturl = s3+http://
## desturl = ftp://myftpuser@ftp.example.org/remote/ftp/path
&lt;strong&gt;desturl = rsync://prod_server@backup//home/prod_server/data&lt;/strong&gt;

# Only if you choose FTP
# ftp_password = whateveryouwant&lt;/pre&gt;

&lt;p&gt;Note that this setup uses symetric encryption for duplicity archives, if you want an asymetric encryption to enforce the safety of your backups, you should &lt;a href=&quot;https://wiki.debian.org/Duplicity&quot; hreflang=&quot;en&quot;&gt;read the docs&lt;/a&gt; and adapt this sample configuration.&lt;/p&gt;

&lt;h3&gt;Configure backupninja update frequency&lt;/h3&gt;

&lt;p&gt;You may have noticed that backupninja set up a cronjob in &lt;code&gt;/etc/cron.d/backupninja&lt;/code&gt; but if you open that file, you will notice that this cronjob runs every hour. Why ? Because this cronjob is only used to start the backup manager, to check if a refresh is needed, not to actually run the backup every hour. You can set the backup frequency in the file &lt;code&gt;/etc/backupninja.conf&lt;/code&gt; :&lt;/p&gt;

&lt;pre&gt;
when = everyday at 01:00&lt;/pre&gt;

&lt;p&gt;Adjust it to your needs, and then save it. Note that you can combo multiple lines, if you want multiple start dates (&lt;a href=&quot;https://labs.riseup.net/code/issues/577&quot; hreflang=&quot;en&quot;&gt;read more&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;Run you first backup, and check it&lt;/h3&gt;

&lt;p&gt;It's time for the first run ! If you don't want to wait for the cronjob, execute your first run with the command &lt;code&gt;backupninja -d -n&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you see no errors, Bravo ! you have configured backupninja !&lt;/p&gt;

&lt;p&gt;Now, let's check our backup : connect to &lt;strong&gt;backup&lt;/strong&gt; and list files under &lt;code&gt;/home/prod_server/data/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should see the files created by duplicity, you cannot use it without some commands :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Show the collection status : &lt;strong&gt;duplicity collection-status file:///home/prod_server/data&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;List files in archive : &lt;strong&gt;duplicity list-current-files file:///home/prod_server/data&lt;/strong&gt;&lt;/li&gt;
	&lt;li&gt;Restore the latest backup in a specific directory &lt;strong&gt;duplicity restore file:///home/prod_server/data/ /home/prod_server/test-restore/&lt;/strong&gt; (if you see errors but files are there after the command, it's because duplicity tries to chown files, while you were not root when starting the command).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that you must&amp;nbsp; have Duplicity installed on &lt;strong&gt;backup&lt;/strong&gt;&amp;nbsp; on in order to use these commands on &lt;strong&gt;backup&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Also note that instead of using &lt;code&gt;file://&lt;/code&gt; on &lt;strong&gt;backup&lt;/strong&gt;, you can run the command on &lt;strong&gt;production&lt;/strong&gt; and use the ssh &lt;code&gt;desturl&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;You should now be able to implement a complete backup solution, using backupninja.&lt;/p&gt;

&lt;p&gt;I hope this post was useful to you, you can write a comment below if you experienced problems with this how-to.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Conflict between broken Apache packages makes FCGI angry (mod_fcgid: can't lock process table)</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2014/02/08/Conflict-between-broken-Apache-packages-makes-FCGI-angry-%28mod_fcgid%3A-can-t-lock-process-table%29</link>
        <guid isPermaLink="false">urn:md5:d9a590ab25d996c14c0fb0f8f7c883e9</guid>
        <pubDate>Sat, 08 Feb 2014 17:37:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>apache</category>
                  <category>apache-itk</category>
                  <category>apache-workers</category>
                  <category>debian</category>
                  <category>fastcgi</category>
                  <category>puppet</category>
                  <category>suexec</category>
                  <category>wheezy</category>
                <description>          &lt;p&gt;Here is is a quick note on the fix I made today for a messed up Apache server.&lt;/p&gt;
&lt;h3&gt;The environment&lt;/h3&gt;
&lt;p&gt;Apache2 + Debian + mod_suexec + mod_fcgi&lt;/p&gt;
&lt;h3&gt;The problem&lt;/h3&gt;
&lt;p&gt;The server was down only for PHP-running websites. It triggered a connexion reset when trying to run PHP scripts. Static content and reverse proxies were working correctly, as if nothing was happening.&lt;/p&gt;
&lt;p&gt;In the server logs, the following error was present&amp;#160;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;code&gt;mod_fcgid: can't lock process table &lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The suexec log was showing no anomaly.&lt;/p&gt;
&lt;p&gt;The server wasn&amp;#8217;t gracefully stopping anymore, and I had to kill him with the &lt;code&gt;-9&lt;/code&gt; signal to stop it.&lt;/p&gt;
&lt;h3&gt;The cause&lt;/h3&gt;
&lt;p&gt;Searching around the web was giving me very few clues on the problem. I couldn&amp;#8217;t find why the CGI subprocess was broken, it is spawned by Apache and so it should not be missing permissions (there is no CGI daemon listening in Apache setup, &lt;a href=&quot;https://uname.pingveno.net/blog/index.php/post/2013/08/25/Configure-Munin-graphs-with-Nginx-and-Debian-7&quot;&gt;contrary to Nginx&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;What causes the Apache subprocesses to get spawned&amp;#160;? Either the Apache &lt;code&gt;mpm-workers&lt;/code&gt;, or &lt;code&gt;mpm-prefork&lt;/code&gt;, or &lt;code&gt;mpm-event&lt;/code&gt; or &lt;code&gt;mpm-itk&lt;/code&gt;. I knew I was using &lt;code&gt;workers&lt;/code&gt;, but a glance in APT installed packages showed me broken packages on &lt;code&gt;workers&lt;/code&gt; and &lt;code&gt;ITK&lt;/code&gt;. Wait&amp;#8230; &lt;code&gt;ITK&lt;/code&gt;&amp;#160;?&lt;/p&gt;
&lt;p&gt;Actually, I run Puppet, and Puppet was configured to keep Apache ot its latest version from repositories. With the release of a newer version of Apache, it had updated the &lt;code&gt;apache2&lt;/code&gt; package &amp;#8230; and installed &lt;code&gt;apache2-mpm-itk&lt;/code&gt; while &lt;code&gt;apache2-mpm-workers&lt;/code&gt; was still present&amp;#160;!&lt;/p&gt;
&lt;p&gt;The result was a conflict while trying to spawn CGI processes, and a crash of the subprocess.&lt;/p&gt;
&lt;h3&gt;The fix&lt;/h3&gt;
&lt;p&gt;Doing a &lt;code&gt;remove apache2-mpm-itk&lt;/code&gt;, and &lt;code&gt;force-reinstall apache2-mpm-workers&lt;/code&gt; did the job.&lt;/p&gt;</description>
        
              </item>
          <item>
        <title>Configure Postfix as standalone single-domain SMTP server using Unix users and PAM on Debian</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2014/02/01/Configure-Postfix-as-STMP-standalone-single-domain-server-using-Unix-users-and-PAM-on-Debian</link>
        <guid isPermaLink="false">urn:md5:e8f08f8049c5bf438f9d352254044c7f</guid>
        <pubDate>Sat, 01 Feb 2014 22:05:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>debian</category>
                  <category>mail</category>
                  <category>note</category>
                  <category>pam</category>
                  <category>postfix</category>
                  <category>sasl</category>
                  <category>server</category>
                <description>          &lt;p&gt;Here is a quick setup to configure Postfix mail server, using existing Unix users.&lt;/p&gt;

&lt;p&gt;The server will process mails for only one domain, and every existing user on the server will have a mail box inside his home directory.&lt;/p&gt;

&lt;h3&gt;Abstract&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; is an &lt;strong&gt;SMTP&lt;/strong&gt; server, it receives incoming mail from other &lt;strong&gt;SMTP&lt;/strong&gt; servers, and allows client to send mails to other &lt;strong&gt;SMTP&lt;/strong&gt; servers.&lt;/p&gt;

&lt;p&gt;What we don't want is an open mail relay. A mail relay is a &lt;strong&gt;SMTP&lt;/strong&gt; server that take anything from any client, and send it to any &lt;strong&gt;SMTP&lt;/strong&gt; server. We only want trusted users to send emails, to prevent anonymous clients from sending spam.&lt;/p&gt;

&lt;p&gt;Incoming mail will be processed either if :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The domain name of one of the recipient matches the mail server domain, and the mail user name is also a system user (&lt;strong&gt;SMTP&lt;/strong&gt; servers can send us incoming mails).&lt;/li&gt;
	&lt;li&gt;The client who tries to sends the mail has successfully authenticated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Postfix&lt;/strong&gt; authentication for clients can be handled by &lt;strong&gt;SASL&lt;/strong&gt;. &lt;strong&gt;SASL&lt;/strong&gt; is a standard protocol to provide an authentication layer. It can query &lt;strong&gt;PAM&lt;/strong&gt;, or other authentication providers (MySQL users, etc).&lt;/p&gt;

&lt;p&gt;Notes :&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;em&gt;We will use PAM for Unix users SMTP authentication.&lt;/em&gt;&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Unix users are stored in&lt;code&gt; /etc/passwd&lt;/code&gt; and their passwords are stored in &lt;code&gt;/etc/shadow&lt;/code&gt;&lt;/em&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;em&gt;Mails will be stored in the ~/Maildir/ of each users, in Maildir format.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Postfix : installation and configuration&lt;/h3&gt;

&lt;p&gt;Install Postfix : &lt;code&gt;apt-get install postfix&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Answer the questions during installation to setup your mail domain (the &quot;example.com&quot; in user@example.com).&lt;/p&gt;

&lt;p&gt;Modify config files :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Configure TLS and Maildir :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;# TLS parameters&lt;br /&gt;
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key&lt;br /&gt;
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem&lt;br /&gt;
smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt&lt;br /&gt;
smtpd_use_tls=yes&lt;br /&gt;
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache&lt;br /&gt;
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache&lt;br /&gt;
&lt;br /&gt;
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for&lt;br /&gt;
# information on enabling SSL in the smtp client.&lt;br /&gt;
&lt;br /&gt;
myhostname = mail.example.com&lt;br /&gt;
alias_maps = hash:/etc/aliases&lt;br /&gt;
alias_database = hash:/etc/aliases&lt;br /&gt;
myorigin = /etc/mailname&lt;br /&gt;
mydestination = example.com, localhost&lt;br /&gt;
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128&lt;br /&gt;
mailbox_size_limit = 0&lt;br /&gt;
recipient_delimiter = +&lt;br /&gt;
&lt;br /&gt;
home_mailbox = Maildir/&lt;br /&gt;
&lt;br /&gt;
# These are the &quot;no relay&quot; restrictions&lt;br /&gt;
smtpd_recipient_restrictions = permit_mynetworks permit_inet_interfaces permit_sasl_authenticated reject_unauth_destination&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;/etc/postfix/master.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;Enable TLS and alternate (submission) ports :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;submission inet n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/submission&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_security_level=encrypt&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;br /&gt;
smtps&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inet&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; smtpd&lt;br /&gt;
&amp;nbsp; -o syslog_name=postfix/smtps&lt;br /&gt;
&amp;nbsp; -o smtpd_tls_wrappermode=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_sasl_auth_enable=yes&lt;br /&gt;
&amp;nbsp; -o smtpd_client_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
&amp;nbsp; -o milter_macro_daemon_name=ORIGINATING&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;SASL : installation and configuration&lt;/h3&gt;

&lt;p&gt;SASL plugin for Postfix (Cyrus) is part of the dependencies of Postfix server.&lt;/p&gt;

&lt;p&gt;Install SASL administration tools : &lt;code&gt;apt-get install sasl2-bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enable SASL daemon at startup : edit &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; and switch &lt;code&gt;START&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Start it manually for the first time : &lt;code&gt;service saslauthd start&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Enable PAM authentication for SASL&lt;/h3&gt;

&lt;p&gt;Check that PAM is part of the MECHANISMS variable in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;MECHANISMS=&quot;pam&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/pam.d/smtp&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;#&lt;br /&gt;
# /etc/pam.d/smtp - specify PAM SMTP behavior&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
@include common-auth&lt;br /&gt;
@include common-account&lt;br /&gt;
@include common-password&lt;br /&gt;
@include common-session&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Enable SASL for Postfix&lt;/h3&gt;

&lt;p&gt;Add to &lt;strong&gt;/etc/postfix/main.cf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;smtpd_sasl_auth_enable = yes&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Create &lt;strong&gt;/etc/postfix/sasl/smtpd.conf&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;pwcheck_method: saslauthd&lt;br /&gt;
mech_list: PLAIN LOGIN&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adjust &lt;code&gt;OPTIONS&lt;/code&gt; in &lt;strong&gt;/etc/default/saslauthd&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;OPTIONS=&quot;-c -m /var/spool/postfix/var/run/saslauthd&quot;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Add &lt;strong&gt;postfix user&lt;/strong&gt; to &lt;strong&gt;sasl group&lt;/strong&gt; :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;adduser postfix sasl&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Configuration check&lt;/h3&gt;

&lt;p&gt;Restart all services (postfix, salsauthd).&lt;/p&gt;

&lt;p&gt;Try authentication using SASL : &lt;code&gt;testsaslauthd -u user -p password&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Try authentication from command line, without mail client : &lt;a href=&quot;https://qmail.jms1.net/test-auth.shtml&quot; hreflang=&quot;en&quot;&gt;https://qmail.jms1.net/test-auth.shtml&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try SMTP reception by sending mail to your domain (your MX fields in domain has to be configured accordingly).&lt;/p&gt;

&lt;h3&gt;Sources&lt;/h3&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#saslauthd&quot; hreflang=&quot;en&quot;&gt;Postfix SASL Howto&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.postfix.org/SASL_README.html#testing_saslauthd&quot; hreflang=&quot;en&quot;&gt;Testing SASL auth&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://blog.ntrippy.net/2008/05/warning-sasl-authentication-failure.html&quot; hreflang=&quot;en&quot;&gt;Fixing SASL authentication failure: cannot connect to saslauthd server: No such file or directory&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.faqforge.com/linux/how-to-enable-port-587-submission-in-postfix/&quot; hreflang=&quot;en&quot;&gt;How to enable submission ports in Postfix&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://www.howtoforge.com/community/threads/cannot-connect-to-saslauthd-server-permission-denied.22730/&quot; hreflang=&quot;en&quot;&gt;Cannot connect to saslauthd : permission denied&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
        
              </item>
          <item>
        <title>Un serveur au régime : faites tourner un serveur complet dans un mouchoir de poche</title>
        <link>https://uname.pingveno.net/blog/index.php/post/2013/11/26/Un-serveur-au-r%C3%A9gime-%3A-faites-tourner-un-serveur-complet-dans-un-mouchoir-de-poche</link>
        <guid isPermaLink="false">urn:md5:e5d93e067cbe67fe57aa1cd33137909c</guid>
        <pubDate>Mon, 25 Nov 2013 07:15:00 +0100</pubDate>
        <dc:creator>Mathieu</dc:creator>
                  <category>Hacks</category>
                          <category>apache</category>
                  <category>debian</category>
                  <category>exim</category>
                  <category>inetd</category>
                  <category>lighttpd</category>
                  <category>linux</category>
                  <category>mysql</category>
                  <category>nginx</category>
                  <category>postgresql</category>
                  <category>serveur</category>
                  <category>sqlite</category>
                  <category>ssmtp</category>
                  <category>swap</category>
                  <category>vsftpd</category>
                <description>          &lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;Ce n&amp;#8217;est pas la période pour les régimes et pourtant aujourd&amp;#8217;hui,
dans un billet volontairement cryptique aux
non-initiés, je vais vous dévoiler les quelques secrets qui permettent à
des nerds invétérés de donner vie à des machines ridiculement pauvres
en RAM. Pour la beauté du geste, mais pas que.&lt;/p&gt;
&lt;p&gt;Je me souviens que l&amp;#8217;on s&amp;#8217;est souvent moqué de moi quand je disais
qu&amp;#8217;avec 512&amp;#160;mégas de RAM on pouvait faire tourner un serveur complet
mail+ftp+web+sql. En remplaçant quelques programmes, vous pouvez parfaitement faire
tourner votre application web standalone, un noeud de CDN performant, un
miroir FTP, ou un relais mail.&lt;/p&gt;
&lt;p&gt;Cet article va simplement vous présenter des alternatives, et terminer avec quelques astuces plus générales. Le but est de remplacer notre célèbre LAMP par des solutions moins gourmandes en mémoire.&lt;/p&gt;
&lt;h3&gt;Remplacer Apache&lt;/h3&gt;
&lt;p&gt;Pour remplacer &lt;strong&gt;Apache&lt;/strong&gt;, nous avons le choix entre &lt;strong&gt;Nginx&lt;/strong&gt; et &lt;strong&gt;Lighttpd&lt;/strong&gt; (&lt;em&gt;Lighty&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Lighttpd&lt;/strong&gt; est le serveur le plus léger au monde. Sa structure est très simple, et l&amp;#8217;impact d&amp;#8217;une connexion en mémoire est très faible.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Nginx&lt;/strong&gt; est un serveur qui consomme un peu plus au démarrage, mais qui utilise une gestion intelligente de ses connexions ouvertes pour optimiser son impact mémoire.&lt;/p&gt;
&lt;p&gt;Inconvénients&amp;#160;: oubliez les &lt;code&gt;.htaccess&lt;/code&gt;, préparez-vous à faire un peu de configuration pour remplacer votre &amp;#8220;&lt;code&gt;a2enmod php5&lt;/code&gt;&amp;#8221;, et changez vos habitudes pour redémarrer les services.&lt;/p&gt;
&lt;h3&gt;Remplacer MySQL&lt;/h3&gt;
&lt;p&gt;Ce n&amp;#8217;est pas facile de remplacer MySQL, tellement le nombre de programme qui en dépendent est conséquent. Cependant, si c&amp;#8217;est possible, n&amp;#8217;hésitez pas une seconde, voici les deux alternatives &amp;#8220;lowcost&amp;#8221; possibles&amp;#160;:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SQLite&lt;/strong&gt;&amp;#160;: une base SQLite est simplement un fichier qui est chargé en mémoire au moment où l&amp;#8217;on veut lire dedans. Pas de démon résident, pas d&amp;#8217;impact lorsque la base est inactive. Par contre, préparez vous à attendre un peu si votre base est conséquente&amp;#160;: lire des données en n&amp;#8217;utilisant que le cache disque,&amp;nbsp; ça peut prendre du temps.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PostgreSQL&lt;/strong&gt;&amp;#160;: PostgreSQL est un peu le nouveau MySQL, mais en mieux. de faible impact mémoire au démarrage, doté de plus de fonctionnalités que MySQL et proposant de meilleures performances, il reste encore marginal mais a tout pour concurrencer les équivalents propriétaires comme Oracle. On peut l&amp;#8217;utiliser dans un environnement limité, en configurant correctement les limites dans sa configuration.&lt;/p&gt;
&lt;h3&gt;Remplacer ProFTPd&lt;/h3&gt;
&lt;p&gt;Si vous proposez un hébergement, vous proposerez certainement un serveur FTP.&lt;/p&gt;
&lt;p&gt;Si les utilisateurs du serveur sont des utilisateurs &amp;#8220;de confiance&amp;#8221; (ie&amp;#160;: que vous connaissez), vous pouvez leur laisser utiliser le serveur &lt;strong&gt;SFTP&lt;/strong&gt; fourni par le serveur SSH (à activer dans la configuration). De très faible impact mémoire, pour une meilleure sécurité et moins de configuration, le protocole SFTP est supporté par la majorité des clients FTP. C&amp;#8217;est LA solution des flemmards pour mettre en place un serveur FTP.&lt;/p&gt;
&lt;p&gt;Sinon, vous pouvez vous rabattre sur un &lt;strong&gt;VSFTPd&lt;/strong&gt;, qui en plus de vous combler au niveau impact mémoire, vous comblera au niveau rapidité. Il gère aussi le &lt;strong&gt;FTPS&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Remplacer Postfix&lt;/h3&gt;
&lt;p&gt;Si vous n&amp;#8217;utilisez pas la réception des mails et que vous ne faites que de l&amp;#8217;envoi (avec ou sans smarthost), &lt;strong&gt;Exim&lt;/strong&gt; vous comblera au moins autant que Postfix, vous proposant même sous Debian une interface de configuration &amp;#8220;pour les nuls&amp;#8221;&amp;#160;: &lt;code&gt;dpkg-reconfigure exim4-config&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Éviter la catastrophe&lt;/h3&gt;
&lt;p&gt;En cas de gonflement inattendu de la mémoire, et lorsque celle-ci commence à manquer, le système d&amp;#8217;exploitation commence à sacrifier des programmes pour libérer de la RAM. C&amp;#8217;est dommage, on aimerait éviter d&amp;#8217;en arriver à de telles extrémités sur un serveur de production.&lt;/p&gt;
&lt;p&gt;La solution est assez simple, bien qu&amp;#8217;imparfaite&amp;#160;: il suffit de rajouter de la SWAP. La SWAP est un fichier d&amp;#8217;échange placé sur le disque dur, lorsque il n&amp;#8217;y a plus de mémoire en RAM, une partie de la RAM est déchargée (ie copiée) sur la SWAP, pour laisser de la place aux programmes &amp;#8220;actifs&amp;#8221;. Bien entendu, cette mémoire déchargée devra être rechargée dès lors qu&amp;#8217;un programme a besoin d&amp;#8217;un bloc mémoire qui a été placé en SWAP, ralentissant le traitement à la vitesse des temps d&amp;#8217;accès disque (pas cool).&lt;/p&gt;
&lt;h3&gt;Faire dormir tout le monde&lt;/h3&gt;
&lt;p&gt;Ce qui est pénible avec les serveurs, c&amp;#8217;est la quantité de RAM qui est là, utilisée en permanence, pour finalement un seul pic d&amp;#8217;utilisation. Si on pouvait récupérer la RAM des programmes qui n&amp;#8217;interagissent pas avec l&amp;#8217;extérieur, et ne les lancer que quand on en a besoin&amp;#160;? &lt;strong&gt;Inetd&lt;/strong&gt; est fait pour ça&amp;#160;!&lt;/p&gt;
&lt;p&gt;Inetd c&amp;#8217;est un &amp;#8220;super démon&amp;#8221; qui va écouter sur les ports demandés à la place des programmes, et qui va lancer les programmes pour traiter l&amp;#8217;événement, dès lors qu&amp;#8217;une connexion est ouverte sur un de ses ports d&amp;#8217;écoute. On peut donc imaginer avoir un Lighttpd non lancé qui se fait réveiller lorsque Inetd reçoit une connexion sur le port 80. Lighttpd traite alors la requête et s&amp;#8217;arrête immédiatement après, laissant la place pour d&amp;#8217;autres programmes.&lt;/p&gt;
&lt;p&gt;L&amp;#8217;inconvénient ici vient des temps de traitement forcément plus longs qu&amp;#8217;avec des démons résidents (démarrer le programme prend du temps).&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Voilà, c&amp;#8217;est à peu près tout, j&amp;#8217;espère qu&amp;#8217;avec ces petits changements dans votre configuration, vous aurez quelques pistes pour alléger votre serveur, si jamais l&amp;#8217;expérience vous tente. &lt;img src=&quot;/blog/themes/mathedit_material3/smilies/wink.png&quot; alt=&quot;;)&quot; class=&quot;smiley&quot;&gt;&lt;/p&gt;</description>
        
              </item>
      </channel>
</rss>
