<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Blog</title><link href="https://blog.tblein.eu/" rel="alternate"></link><link href="https://blog.tblein.eu/feeds/server.atom.xml" rel="self"></link><id>https://blog.tblein.eu/</id><updated>2016-08-27T00:00:00+02:00</updated><entry><title>Automatic deployment of pelican website with GitLab - The local way</title><link href="https://blog.tblein.eu/server/2016/automatic-deployment-of-pelican-website-with-gitlab-the-local-way/" rel="alternate"></link><published>2016-08-27T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-27:server/2016/automatic-deployment-of-pelican-website-with-gitlab-the-local-way/</id><summary type="html">&lt;p&gt;We already saw a way to &lt;a class="reference external" href="https://blog.tblein.eu/server/2016/automatic-deployment-of-pelican-website-with-gitlab/"&gt;deploy our pelican website&lt;/a&gt;. To do it
we add a SSH private SSH key to the environment variables. That not so nice
since everybody that have access to the project can get the SSH private key.  We
will see here an other possibility to deploy our pelican website by mounting the
final repository directly inside the build environment.&lt;/p&gt;
&lt;p&gt;You will need to have functional installation of GitLab and GitLab Runner with
Docker. In addition we suppose that the required python are in the
&lt;code&gt;requirements.txt&lt;/code&gt; file. The build and deployment will be managed with
python and classical tools like &lt;code&gt;mv&lt;/code&gt;, so a minimal docker image with
python should be enough to do the job. The GitLab Runner should be on the
machine that serve the website.&lt;/p&gt;
&lt;div class="section" id="create-a-runner"&gt;
&lt;h2&gt;Create a runner&lt;/h2&gt;
&lt;p&gt;We will first create a runner that use docker that have python 2 installation
and the web destination folder mounted (in our case it will be
&lt;code&gt;/var/www&lt;/code&gt;).&lt;/p&gt;
&lt;div class="section" id="general-runner-registration"&gt;
&lt;h3&gt;General runner registration&lt;/h3&gt;
&lt;p&gt;If not already done, you will need to setup a runner for the project:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; gitlab-runner register
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Put the address of the coordinator. If GitLab is accessible trough &lt;a class="reference external" href="http://gitlab.com"&gt;http://gitlab.com&lt;/a&gt;,
it should be something like &lt;a class="reference external" href="http://gitlab.com/ci"&gt;http://gitlab.com/ci&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enter then the token that will link GitLab and the runner:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;If you would like to have a shared runner go to the &lt;cite&gt;Admin Area&lt;/cite&gt;, then
&lt;cite&gt;Overview&lt;/cite&gt; and finally &lt;cite&gt;Runners&lt;/cite&gt;, to get the token.&lt;/li&gt;
&lt;li&gt;If you prefer to have a runner for the project, go in the configuration menu
of the projects and select &lt;cite&gt;Runners&lt;/cite&gt; and use the token of the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Give a name to your runner and eventually some tags. I suggest to had as tags
all the functionality of the runner. Indeed we can specify in the build system
to use only the runners that carry specified tags. In our example the tags will
be &lt;code&gt;python2&lt;/code&gt;, &lt;code&gt;www-mount&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Specify the executor as &lt;code&gt;docker&lt;/code&gt; and the docker image as
&lt;code&gt;python:2-alpine&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-of-the-mounted-volume"&gt;
&lt;h3&gt;Configuration of the mounted volume&lt;/h3&gt;
&lt;p&gt;At the creation of the runner, automatically a volume is created as cache
(&lt;code&gt;/cache&lt;/code&gt;). We will add an other one that will be linked to a real path on
the machine running the gitlab-ci-multi-runner.&lt;/p&gt;
&lt;p&gt;To do it we need to edit the &lt;code&gt;/etc/gitlab-runner/config.toml&lt;/code&gt;. Search the
runner you are interested and change the &lt;code&gt;volumes&lt;/code&gt; line as follow:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;volumes = [&amp;quot;/cache&amp;quot;, &amp;quot;/var/www:/var/www:rw&amp;quot;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each time the runner will be executed the &lt;code&gt;/var/www&lt;/code&gt; folder of the host at
the same place in the container as read write.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="deployment"&gt;
&lt;h2&gt;Deployment&lt;/h2&gt;
&lt;p&gt;Here are the different steps for the deployment.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Clone the repository.&lt;/li&gt;
&lt;li&gt;First install dependencies with the help of pip and the
&lt;code&gt;requirements.txt&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Generate pelican website.&lt;/li&gt;
&lt;li&gt;Backup the old version of the website (just in case)&lt;/li&gt;
&lt;li&gt;Move the output directory in the destination&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="configuration-of-the-continuous-integration"&gt;
&lt;h3&gt;Configuration of the continuous integration&lt;/h3&gt;
&lt;p&gt;We will create a Gitlab continuous integration configuration file
(&lt;code&gt;.gitlab-ci.yml&lt;/code&gt;) at the root of the repository. It is automatically
recognised by GitLab. The file is inspired from the one proposed by GitLab.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;image&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;python:2.7-alpine&lt;/span&gt;

&lt;span class="l l-Scalar l-Scalar-Plain"&gt;pages&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="l l-Scalar l-Scalar-Plain"&gt;tags&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;www-mount&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;python2&lt;/span&gt;
  &lt;span class="l l-Scalar l-Scalar-Plain"&gt;script&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;pip install -r requirements.txt&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;pelican -s publishconf.py&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;mv -f /var/www/website.domain /var/www/archives/website.domain.$(date &amp;quot;+%Y%m%d_%H%M%S&amp;quot;) || true&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;mv output /var/www/website.domain&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For the build we specify two tags here: &lt;code&gt;www-mount&lt;/code&gt; and &lt;code&gt;python2&lt;/code&gt;.
This will allow the build system to select the runner that have the same tags.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://gitlab.com/pages/pelican"&gt;pages / pelican&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/configuration/advanced-configuration.md"&gt;gitlab-ci-multi-runner -- Advanced configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="GitLab"></category><category term="pelican"></category><category term="deploy"></category><category term="Debian"></category><category term="Docker."></category></entry><entry><title>PHP activation for nginx</title><link href="https://blog.tblein.eu/server/2016/php-activation-for-nginx/" rel="alternate"></link><published>2016-08-20T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-20:server/2016/php-activation-for-nginx/</id><summary type="html">&lt;p&gt;We will see how to let nginx execute PHP scripts and display their results
instead of their content.&lt;/p&gt;
&lt;div class="section" id="configuration-of-php-fpm"&gt;
&lt;h2&gt;Configuration of PHP-FPM&lt;/h2&gt;
&lt;p&gt;Several possibility are available to execute PHP scripts Apache module, CGI,
FastCGI and FPM. The later is an adaptation of the FastCGI version for
heavy-loaded sites. It is the recommended installation to use with nginx.&lt;/p&gt;
&lt;p&gt;We will start by installing the FPM version of PHP5&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; apt install php5-fpm
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;nginx can discuss with the PHP-FPM process either through TCP socket or Unix
socket. Since we will suppose nginx and PHP-FPM are on the same machine, we will
use the Unix socket version.&lt;/p&gt;
&lt;p&gt;First we check the configuration in the PHP-FPM configuration file
(&lt;code&gt;php5/fpm/pool.d/www.conf&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;38 &lt;/span&gt;&lt;span class="na"&gt;listen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/var/run/php5-fpm.sock&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we restart the PHP-FPM service&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service php5-fpm restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-of-nginx"&gt;
&lt;h2&gt;Configuration of nginx&lt;/h2&gt;
&lt;p&gt;We say to nginx where to find the PHP socket and to pass it the PHP files
(extension &lt;code&gt;.php&lt;/code&gt;). We need to put the following lines in the vhost files
needing it. For the ease of the host configuration just put that lines in a new
file called &lt;code&gt;/etc/nginx/php.conf&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# pass the PHP scripts to PHP-FPM server listening on :code:`/var/run/php5-fpm.sock;`&lt;/span&gt;

&lt;span class="k"&gt;location&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt; &lt;span class="sr"&gt;\.php$&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;include&lt;/span&gt; &lt;span class="s"&gt;snippets/fastcgi-php.conf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;# With php5-fpm:&lt;/span&gt;
    &lt;span class="kn"&gt;fastcgi_pass&lt;/span&gt; &lt;span class="s"&gt;unix:/var/run/php5-fpm.sock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You will just need to include that file in the virtual host that need to execute
php scripts. For example for the default site
(&lt;code&gt;/etc/nginx/sites-available/default&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt; 1 &lt;/span&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt; 2 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt; &lt;span class="s"&gt;default_server&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 3 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="s"&gt;[::]:80&lt;/span&gt; &lt;span class="s"&gt;default_server&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 4 &lt;/span&gt;
&lt;span class="lineno"&gt; 5 &lt;/span&gt;    &lt;span class="kn"&gt;root&lt;/span&gt; &lt;span class="s"&gt;/var/www/html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 6 &lt;/span&gt;
&lt;span class="lineno"&gt; 7 &lt;/span&gt;    &lt;span class="c1"&gt;# Add index.php to the list if you are using PHP&lt;/span&gt;
&lt;span class="lineno"&gt; 8 &lt;/span&gt;    &lt;span class="kn"&gt;index&lt;/span&gt; &lt;span class="s"&gt;index.html&lt;/span&gt; &lt;span class="s"&gt;index.htm&lt;/span&gt; &lt;span class="s"&gt;index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 9 &lt;/span&gt;
&lt;span class="lineno"&gt;10 &lt;/span&gt;    &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;11 &lt;/span&gt;
&lt;span class="lineno"&gt;12 &lt;/span&gt;    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="s"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;13 &lt;/span&gt;        &lt;span class="c1"&gt;# First attempt to serve request as file, then&lt;/span&gt;
&lt;span class="lineno"&gt;14 &lt;/span&gt;        &lt;span class="c1"&gt;# as directory, then fall back to displaying a 404.&lt;/span&gt;
&lt;span class="lineno"&gt;15 &lt;/span&gt;        &lt;span class="kn"&gt;try_files&lt;/span&gt; &lt;span class="nv"&gt;$uri&lt;/span&gt; &lt;span class="nv"&gt;$uri/&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;16 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;17 &lt;/span&gt;    &lt;span class="kn"&gt;include&lt;/span&gt; &lt;span class="s"&gt;php.conf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;18 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A restart of nginx is then necessary to take the new configuration into account:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service nginx restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://www.guillaume-leduc.fr/projet-installation-configuration-nginx-php-fpm.html"&gt;Installation et configuration de Nginx et PHP-FPM pour CakePHP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://nl3.php.net/manual/en/install.fpm.php"&gt;FastCGI Process Manager (FPM)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="nginx"></category><category term="Debian"></category><category term="PHP"></category></entry><entry><title>Two factor authentication</title><link href="https://blog.tblein.eu/server/2016/two-factor-authentication/" rel="alternate"></link><published>2016-08-15T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-15:server/2016/two-factor-authentication/</id><summary type="html">&lt;p&gt;One time password are now spread in a lot of web services. They are valid only
for a session and therefore even if intercept they can be used only once. Two
methods are normalised by the &lt;a class="reference external" href="http://www.openauthentication.org/"&gt;Initiative For Open Authentication&lt;/a&gt; (OATH):&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;time based one-time password algorithm (TOTP) that is based on the combination
of time and a shared secret to generate the unique password.&lt;/li&gt;
&lt;li&gt;HMAC-based one-time password algorithm (HOTP) that is based on the combination
of number of connection and a shared secret to generate the unique password.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To be able to use it, the user will need to have an application most of the time
on her phone that generate the code asked by the server.  The two algorithms are
freely available as open standard and therefore numerous application are
available to use them. The most known one is &lt;a class="reference external" href="https://github.com/google/google-authenticator"&gt;Google Authenticator&lt;/a&gt; That provide both a PAM
module (for the setting on the server) and a phone application (for the user).
However other phone application are available such as &lt;a class="reference external" href="https://fedorahosted.org/freeotp/"&gt;FreeOTP&lt;/a&gt;&lt;/p&gt;
&lt;div class="section" id="installation-of-the-pam-module"&gt;
&lt;h2&gt;Installation of the PAM module&lt;/h2&gt;
&lt;p&gt;Google developed a PAM module implementing the OATH-TOTP and OATH-HOTP. Its
installation and configuration is simple. Since it is available in Debian
repository to install it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; apt install libpam-google-authenticator
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After installation to use it on any PAM authentication module you need to a open
the correct file and add the following line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;auth required pam_google_authenticator.so nullok
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;nullok&lt;/code&gt; parameter allow the connection of the user without two factor
authentication setup to connect normally.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="activation-for-su"&gt;
&lt;h2&gt;Activation for &lt;code&gt;su&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Only need to madify the su PAM module in &lt;code&gt;/etc/pam.d/su&lt;/code&gt;. Add the
pam_google_authenticator line after pam_rootok.so&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;# This allows root to su without passwords (normal operation)
auth       sufficient pam_rootok.so
auth       required     pam_google_authenticator.so nullok
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="activation-for-ssh-server"&gt;
&lt;h2&gt;Activation for SSH server&lt;/h2&gt;
&lt;p&gt;First configure SSH PAM authentication module in &lt;code&gt;/etc/pam.d/sshd&lt;/code&gt;. Had at
the end of the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;auth required pam_google_authenticator.so nullok
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; change the value of
&lt;code&gt;ChallengeResponseAuthentication&lt;/code&gt; from &lt;code&gt;no&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By default the authentication will be managed as follow:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;User that connect with a SSH key will log as usual&lt;/li&gt;
&lt;li&gt;User that log with a password will in addition need to respond to a OTP
challenge.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ssh user@server
&lt;span class="go"&gt;Password:&lt;/span&gt;
&lt;span class="go"&gt;Verification code:&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="setting-totp-for-an-user"&gt;
&lt;h2&gt;Setting TOTP for an user&lt;/h2&gt;
&lt;p&gt;We will see here how to setup TOTP parameter for an user. It will be used by any
PAM module where &lt;code&gt;pam_google_authenticator&lt;/code&gt; is activated.&lt;/p&gt;
&lt;p&gt;Login as the desired user and run &lt;code&gt;google-authenticator&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; google-authenticator

&lt;span class="go"&gt;Do you want authentication tokens to be time-based (y/n)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Answer &lt;cite&gt;yes&lt;/cite&gt; to the first question to have time based on one time password
(TOTP) or no to get HMAC-based one time password (HOTP). It will generate the
shared code and display in your console a QR code ready to be scanned by your
phone. If not displayed, you can open the link given to open the QR code. An
example output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;https://www.google.com/chart?chs=200x200&amp;amp;chld=M|0&amp;amp;cht=qr&amp;amp;chl=otpauth://totp/user@server%3Fsecret%&lt;/span&gt;3DHENVXKRO4RFDSRDK

&lt;span class="go"&gt;Your new secret key is: HENVXKRO4RFDSRDK&lt;/span&gt;
&lt;span class="go"&gt;Your verification code is 580768&lt;/span&gt;
&lt;span class="go"&gt;Your emergency scratch codes are:&lt;/span&gt;
&lt;span class="go"&gt;28520578&lt;/span&gt;
&lt;span class="go"&gt;41297079&lt;/span&gt;
&lt;span class="go"&gt;99231833&lt;/span&gt;
&lt;span class="go"&gt;99978459&lt;/span&gt;
&lt;span class="go"&gt;29834705&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In addition to the key it give you a verification code. This is the code
generated at the time of QR code generation to be sure that is correctly
entered. It give you also 5 emergency scratch codes that can be used at any time
to login. They need of course to stored in a safe place.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;Do you want me to update your &amp;quot;/home/user/.google_authenticator&amp;quot; file (y/n)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Answer &lt;cite&gt;yes&lt;/cite&gt; to allow the module to setup the needed file for the
authentication. Your secret key the different parameters and the emergency
scratch codes will be saved in this file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;Do you want to disallow multiple uses of the same authentication&lt;/span&gt;
&lt;span class="go"&gt;token? This restricts you to one login about every 30s, but it increases&lt;/span&gt;
&lt;span class="go"&gt;your chances to notice or even prevent man-in-the-middle attacks (y/n)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Answer &lt;cite&gt;yes&lt;/cite&gt; to allow only one utilisation of each password. It will block you
to login twice in less than 30 seconds (default time resolution for password
generation).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;By default, tokens are good for 30 seconds and in order to compensate for&lt;/span&gt;
&lt;span class="go"&gt;possible time-skew between the client and the server, we allow an extra&lt;/span&gt;
&lt;span class="go"&gt;token before and after the current time. If you experience problems with poor&lt;/span&gt;
&lt;span class="go"&gt;time synchronization, you can increase the window from its default&lt;/span&gt;
&lt;span class="go"&gt;size of 1:30min to about 4min. Do you want to do so (y/n)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Answer &lt;cite&gt;no&lt;/cite&gt;, the allowed timing of the password will be +/- 30 seconds. For most
of the case it will be largely sufficient.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;If the computer that you are logging into isn&amp;#39;t hardened against brute-force&lt;/span&gt;
&lt;span class="go"&gt;login attempts, you can enable rate-limiting for the authentication module.&lt;/span&gt;
&lt;span class="go"&gt;By default, this limits attackers to no more than 3 login attempts every 30s.&lt;/span&gt;
&lt;span class="go"&gt;Do you want to enable rate-limiting (y/n) y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Answer &lt;cite&gt;yes&lt;/cite&gt;, it does not cost so much to strength the access even if the server
already have some protection against brute force attack (like fail2ban).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="source"&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://www.digitalocean.com/community/tutorials/how-to-set-up-multi-factor-authentication-for-ssh-on-ubuntu-14-04"&gt;How To Set Up Multi-Factor Authentication for SSH on Ubuntu 14.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://en.wikipedia.org/wiki/One-time_password"&gt;One-time password&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://changelog.complete.org/archives/9707-easily-improving-linux-security-with-two-factor-authentication"&gt;Easily Improving Linux Security with Two-Factor Authentication&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="su"></category><category term="SSH"></category><category term="Debian"></category><category term="authentication"></category><category term="OATH-TOTP"></category><category term="OATH-HOTP"></category></entry><entry><title>Nginx as a proxy</title><link href="https://blog.tblein.eu/server/2016/nginx-as-a-proxy/" rel="alternate"></link><published>2016-08-13T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-13:server/2016/nginx-as-a-proxy/</id><summary type="html">&lt;p&gt;We will see how to setup Nginx as a proxy to other web server. I used this
configuration while transiting from lighttpd to Nginx. After installing Nginx
I setup it to redirect all the web traffic to the lighttpd serrver. The aimed is
to switch gradually from Nginx to lighttpd the different services served by
lighttpd we as little interruption as possible.&lt;/p&gt;
&lt;div class="section" id="setup-of-the-proxy-for-web-traffic"&gt;
&lt;h2&gt;Setup of the proxy for web traffic&lt;/h2&gt;
&lt;p&gt;An example of configuration file to transfer all request on port 80 to an other
web server listening on port 8080.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt; 1 &lt;/span&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt; 2 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 3 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="s"&gt;[::]:80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 4 &lt;/span&gt;    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="s"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt; 5 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt;  &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 6 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 7 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 8 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_pass&lt;/span&gt;
&lt;span class="lineno"&gt; 9 &lt;/span&gt;        &lt;span class="s"&gt;http://127.0.0.1:8080/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;10 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;11 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;proxy_set_header Host&lt;/code&gt; allow to tranfer address at which the proxy
had been reach. Therefore, if the server listening on port 8080 as virtualhost
they will work.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="setup-of-the-proxy-for-encrypted-web-traffic"&gt;
&lt;h2&gt;Setup of the proxy for encrypted web traffic&lt;/h2&gt;
&lt;p&gt;This is an enhancement of the previous one that redirect the traffic of port 443
to a https server listening on port 8081. In our case the TLS encrypted
connection is setup on the proxy and the web server with letsencrypt and use the
same certificates.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt; 1 &lt;/span&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt; 2 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 3 &lt;/span&gt;    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="s"&gt;[::]:443&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 4 &lt;/span&gt;    &lt;span class="kn"&gt;ssl&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 5 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_protocols&lt;/span&gt; &lt;span class="s"&gt;TLSv1.2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 6 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_certificate&lt;/span&gt; &lt;span class="s"&gt;/etc/letsencrypt/live/mydomain.tld/fullchain.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 7 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_certificate_key&lt;/span&gt; &lt;span class="s"&gt;/etc/letsencrypt/live/mydomain.tld/privkey.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 8 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_dhparam&lt;/span&gt; &lt;span class="s"&gt;/etc/ssl/certs/dhparam.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt; 9 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_ecdh_curve&lt;/span&gt; &lt;span class="s"&gt;secp384r1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;10 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;11 &lt;/span&gt;    &lt;span class="kn"&gt;ssl_ciphers&lt;/span&gt; &lt;span class="s"&gt;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;12 &lt;/span&gt;    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="s"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;13 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;14 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;15 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;16 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-Proto&lt;/span&gt; &lt;span class="nv"&gt;$scheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;17 &lt;/span&gt;        &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;Front-End-Https&lt;/span&gt; &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;18 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;https://127.0.0.1:8081/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;19 &lt;/span&gt;        &lt;span class="kn"&gt;proxy_redirect&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="lineno"&gt;20 &lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;21 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://homeserver-diy.net/wiki/index.php?title=Utilisation_d%27Nginx_comme_reverse_proxy_avec_un_certificat_auto-sign%C3%A9,_Let%27s_Encrypt_et_un_chiffrement_fort"&gt;Utilisation d'Nginx comme reverse proxy avec un certificat auto-signé, Let's
Encrypt et un chiffrement fort&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="Debian"></category><category term="Web"></category><category term="nginx"></category><category term="proxy"></category><category term="SSL"></category></entry><entry><title>Automatic deployment of pelican website with GitLab</title><link href="https://blog.tblein.eu/server/2016/automatic-deployment-of-pelican-website-with-gitlab/" rel="alternate"></link><published>2016-08-03T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-03:server/2016/automatic-deployment-of-pelican-website-with-gitlab/</id><summary type="html">&lt;p&gt;Using static site generator like &lt;a class="reference external" href="http://docs.getpelican.com"&gt;Pelican&lt;/a&gt;
involved to rebuild it each time you modify it. Modern software forge like
&lt;a class="reference external" href="https://about.gitlab.com/"&gt;GitLab&lt;/a&gt; are able not only to manage code
repositories but also make some continuous integration. Therefore they are able
to run some command after each commit such as test, or build. In our case we
will see how to rebuild and deploy our pelican website at each commit.&lt;/p&gt;
&lt;p&gt;You will need to have functional installation of GitLab and GitLab Runner with
Docker. In addition we suppose that the required python are in the
&lt;code&gt;requirements.txt&lt;/code&gt; file. The build and deployment will be managed with the
make and therefore the Pelican generated &lt;code&gt;Makefile&lt;/code&gt; should be correctly
setup and notably the SCP parameters that will be used.&lt;/p&gt;
&lt;div class="section" id="create-a-runner"&gt;
&lt;h2&gt;Create a runner&lt;/h2&gt;
&lt;p&gt;If not already done, you will need to setup a runner for the project:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; gitlab-runner register
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Put the address of the coordinator. If GitLab is accessible trough &lt;a class="reference external" href="http://gitlab.com"&gt;http://gitlab.com&lt;/a&gt;,
it should be something like &lt;a class="reference external" href="http://gitlab.com/ci"&gt;http://gitlab.com/ci&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enter then the token that will link GitLab and the runner:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;If you would like to have a shared runner go to the &lt;cite&gt;Admin Area&lt;/cite&gt;, then
&lt;cite&gt;Overview&lt;/cite&gt; and finally &lt;cite&gt;Runners&lt;/cite&gt;, to get the token.&lt;/li&gt;
&lt;li&gt;If you prefer to have a runner for the project, go in the configuration menu
of the projects and select &lt;cite&gt;Runners&lt;/cite&gt; and use the token of the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Give a name to your runner and eventually some tags.&lt;/p&gt;
&lt;p&gt;Specify the executor as &lt;code&gt;docker&lt;/code&gt; and the docker image as
&lt;code&gt;python:2.7&lt;/code&gt;. This docker image not only include python but also some
development tools such as GNU Make.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="deployment"&gt;
&lt;h2&gt;Deployment&lt;/h2&gt;
&lt;p&gt;Here are the different steps for the deployment.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Clone the repository.&lt;/li&gt;
&lt;li&gt;First install dependencies with the help of pip and the
&lt;code&gt;requirements.txt&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Setup a SSH configuration directory with correct POSIX right (&lt;code&gt;~/.ssh&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Get the SSH public key of the server and had it to known_hosts with the
&lt;code&gt;ssh-keyscan&lt;/code&gt; command.&lt;/li&gt;
&lt;li&gt;Create the required private key files (from &lt;code&gt;SSH_PRIVATE_KEY&lt;/code&gt;
environment variable). This will allow us to have it outside of the repository
and therefore secret.&lt;/li&gt;
&lt;li&gt;Generate pelican and upload to the ssh server with the help of &lt;code&gt;make&lt;/code&gt;
command.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="setup-of-the-private-ssh-key"&gt;
&lt;h3&gt;Setup of the private SSH key&lt;/h3&gt;
&lt;p&gt;To avoid to have the private SSH key in the repository and therefore able to be
read by everybody accessing it, we will save it in a GitLab Internal variable.&lt;/p&gt;
&lt;p&gt;Put the content of the private key in a variable named &lt;code&gt;SSH_PRIVATE_KEY&lt;/code&gt;.
For this in the configuration menu of the project select &lt;cite&gt;Variables&lt;/cite&gt; and create
a new one with the name &lt;cite&gt;SSH_PRIVATE_KEY&lt;/cite&gt; and put the content of &lt;code&gt;id_rsa&lt;/code&gt;
corresponding that is in between the &lt;code&gt;-----BEGIN RSA PRIVATE KEY-----&lt;/code&gt; and
&lt;code&gt;-----END RSA PRIVATE KEY-----&lt;/code&gt; as a value. This variables will be
specific to the project and available in the build environment. We will need to
past this key in the correct file to be able to use it for SSH connection.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-of-the-continuous-integration"&gt;
&lt;h3&gt;Configuration of the continuous integration&lt;/h3&gt;
&lt;p&gt;We will create a Gitlab continuous integration configuration file
(&lt;code&gt;.gitlab-ci.yml&lt;/code&gt;) at the root of the repository. It is automatically
reconnised by GitLab. The file is inspired from the one proposed by GitLab.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;image&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;python:2&lt;/span&gt;

&lt;span class="l l-Scalar l-Scalar-Plain"&gt;pages&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="l l-Scalar l-Scalar-Plain"&gt;script&lt;/span&gt;&lt;span class="p p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;pip install -r requirements.txt&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;mkdir -p ~/.ssh&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;chmod 700 ~/.ssh&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;ssh-keyscan -t rsa domaine.tld &amp;gt; ~/.ssh/known_hosts&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;echo &amp;quot;-----BEGIN RSA PRIVATE KEY-----&amp;quot; &amp;gt; ~/.ssh/id_rsa&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;echo &amp;quot;$SSH_PRIVATE_KEY&amp;quot; &amp;gt;&amp;gt; ~/.ssh/id_rsa&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;echo &amp;quot;-----END RSA PRIVATE KEY-----&amp;quot; &amp;gt;&amp;gt; ~/.ssh/id_rsa&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;chmod 600 ~/.ssh/id_rsa&lt;/span&gt;
  &lt;span class="p p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l l-Scalar l-Scalar-Plain"&gt;make ssh_upload&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://gitlab.com/pages/pelican"&gt;pages / pelican&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="GitLab"></category><category term="pelican"></category><category term="deploy"></category><category term="Debian"></category><category term="Docker."></category></entry><entry><title>Gitlab-runner installation</title><link href="https://blog.tblein.eu/server/2016/gitlab-runner-installation/" rel="alternate"></link><published>2016-08-03T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-08-03:server/2016/gitlab-runner-installation/</id><summary type="html">&lt;div class="section" id="installation-of-docker"&gt;
&lt;h2&gt;Installation of Docker&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://docs.docker.com/engine/installation/linux/debian/"&gt;https://docs.docker.com/engine/installation/linux/debian/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="install-gitlab-ci-multi-runner"&gt;
&lt;h2&gt;Install gitlab-ci-multi-runner&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/linux-repository.md"&gt;https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/linux-repository.md&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Add gitlab-runner user to docker group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; gpasswd -a gitlab-runner docker
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restart Docker service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service docker restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="create-a-runner"&gt;
&lt;h2&gt;Create a runner&lt;/h2&gt;
&lt;p&gt;Register a runner&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; gitlab-runner register
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Put the address of the coordinator. If Gitlab is accessible trough &lt;a class="reference external" href="http://gitlab.com"&gt;http://gitlab.com&lt;/a&gt;,
it should be something like &lt;a class="reference external" href="http://gitlab.com/ci"&gt;http://gitlab.com/ci&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enter then the token that will link Gitlab and the runner:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;If you would like to have a shared runner go to the &lt;cite&gt;Admin Area&lt;/cite&gt;, then
&lt;cite&gt;Overview&lt;/cite&gt; and finally &lt;cite&gt;Runners&lt;/cite&gt;, to get the token.&lt;/li&gt;
&lt;li&gt;If you prefer to have a runner for the project, go in the configuration menu
of the projects and select &lt;cite&gt;Runners&lt;/cite&gt; and use the token of the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Give a name to your runner and eventually some tags.&lt;/p&gt;
&lt;p&gt;Specify the executor as &lt;code&gt;docker&lt;/code&gt; and the docker image as &lt;code&gt;python:2&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="Git Lab"></category><category term="Git Lab Runner"></category><category term="deploy"></category><category term="Debian"></category></entry><entry><title>Easy firewall with ferm</title><link href="https://blog.tblein.eu/server/2016/Easy-firewall-with-ferm/" rel="alternate"></link><published>2016-07-27T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-27:server/2016/Easy-firewall-with-ferm/</id><summary type="html">&lt;p&gt;It is a simplify interface to &lt;code&gt;iptable&lt;/code&gt;, it allow therefore to configure
the firewall with rules easier to read than iptable ones.&lt;/p&gt;
&lt;div class="section" id="installation"&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; apt install ferm
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration"&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;The configuration takes place in the &lt;code&gt;/etc/ferm/ferm.conf&lt;/code&gt; file. By
default, only port 22 is open allowing SSH connexions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;proto&lt;/span&gt; &lt;span class="n"&gt;tcp&lt;/span&gt; &lt;span class="n"&gt;dport&lt;/span&gt; &lt;span class="n"&gt;ssh&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To open port you only need to enter similar rules. Port can be specified by its
number or by the name of the service that it is associated with it. To
determined the name of the service associated with a port you just have to look
inside the &lt;code&gt;/etc/services&lt;/code&gt; file.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://ferm.foo-projects.org"&gt;ferm - for Easy Rule Making&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="firewall"></category><category term="ferm"></category></entry><entry><title>Executing a command at login</title><link href="https://blog.tblein.eu/server/2016/Executing-a-command-at-login/" rel="alternate"></link><published>2016-07-26T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-26:server/2016/Executing-a-command-at-login/</id><summary type="html">&lt;p&gt;Under Linux, the connexion is handle by the PAM (Pluggable Authentication
Modules) authentication system. As is name said it, the functionality are spread
in different modules like authentication backend (like LDAP, NSS) or action to
do at connexion (like folder mounting).&lt;/p&gt;
&lt;div class="section" id="pam-exec"&gt;
&lt;h2&gt;pam_exec&lt;/h2&gt;
&lt;p&gt;The &lt;a class="reference external" href="http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_exec.html"&gt;pam_exec&lt;/a&gt;
module allows to execute an arbitrary command while connecting. Therefore it is
possible to do what ever we want.&lt;/p&gt;
&lt;p&gt;To activate it you only need to add the following line in your
&lt;code&gt;/etc/pam.d/common-session&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;span class="err"&gt;session&lt;/span&gt;    &lt;span class="err"&gt;optional&lt;/span&gt;     &lt;span class="err"&gt;pam_exec.so&lt;/span&gt;    &lt;span class="err"&gt;command&lt;/span&gt;
&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Replace &lt;code&gt;command&lt;/code&gt; by the name of the command to execute.&lt;/p&gt;
&lt;p&gt;Several environments variables are set so that can be used inside the program:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;$PAM_TYPE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$PAM_USER&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$PAM_RUSER&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$PAM_RHOST&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$PAM_SERVICE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;$PAM_TTY&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="email-notification-of-a-connexion"&gt;
&lt;h2&gt;Email notification of a connexion&lt;/h2&gt;
&lt;p&gt;One of the classical function of this module is to send an email notification
while a user is login. For this we will create the
&lt;code&gt;/usr/local/bin/send-mail-on-login.sh&amp;gt;&lt;/code&gt; script with the following
functionality :
- only work at the opening of new connexions
- only for a limited number of user (for example &lt;code&gt;admin&lt;/code&gt; and &lt;code&gt;root&lt;/code&gt;)
- send by email the connexion information to the administrator (&lt;code&gt;admin&lt;/code&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;([&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$PAM_TYPE&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;open_session&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
    &lt;span class="o"&gt;([&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$PAM_USER&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;root&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
     &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$PAM_USER&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; !&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;admin&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]))&lt;/span&gt;
&lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;User: &lt;/span&gt;&lt;span class="nv"&gt;$PAM_USER&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Remote Host: &lt;/span&gt;&lt;span class="nv"&gt;$PAM_RHOST&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Service: &lt;/span&gt;&lt;span class="nv"&gt;$PAM_SERVICE&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;TTY: &lt;/span&gt;&lt;span class="nv"&gt;$PAM_TTY&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Date: `date`&amp;quot;&lt;/span&gt;
        &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Server: `uname -a`&amp;quot;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt; mail -s &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$PAM_SERVICE&lt;/span&gt;&lt;span class="s2"&gt; login on `hostname -s` for account &lt;/span&gt;&lt;span class="nv"&gt;$PAM_USER&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; root
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Do not forget to let the script executable by running the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; chmod + x /usr/local/bin/send-mail-on-login.sh
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And to modify &lt;code&gt;/etc/pam.d/common-session&lt;/code&gt; file accordingly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;span class="err"&gt;session&lt;/span&gt;    &lt;span class="err"&gt;optional&lt;/span&gt;     &lt;span class="err"&gt;pam_exec.so&lt;/span&gt;    &lt;span class="err"&gt;/usr/local/bin/send-mail-on-login.sh&lt;/span&gt;
&lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now at each connexion of &lt;code&gt;root&lt;/code&gt; or &lt;code&gt;admin&lt;/code&gt;, an email will be send to
the administrator. For example after a ssh connexion of &lt;code&gt;admin&lt;/code&gt; the
administrator will receive a email like the following one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;User: admin&lt;/span&gt;
&lt;span class="go"&gt;Remote Host: dslb-000-000-000-000.pools.arcor-ip.net&lt;/span&gt;
&lt;span class="go"&gt;Service: sshd&lt;/span&gt;
&lt;span class="go"&gt;TTY: ssh&lt;/span&gt;
&lt;span class="go"&gt;Date: mercredi 22 juin 2011, 22:46:38 (UTC+0200)&lt;/span&gt;
&lt;span class="go"&gt;Server: Linux test 2.6.32-5-amd64 #1 SMP Mon Mar 7 21:35:22 UTC 2011 x86_64 GNU/Linux&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="source"&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://linux-attitude.fr/post/pam_exec"&gt;Scripting avec pam_exec, notification de connexion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="connection"></category><category term="PAM"></category><category term="mail"></category></entry><entry><title>LDAP authentication for lighttpd</title><link href="https://blog.tblein.eu/server/2016/LDAP-authentication-for-lighttpd/" rel="alternate"></link><published>2016-07-26T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-26:server/2016/LDAP-authentication-for-lighttpd/</id><summary type="html">&lt;p&gt;Like a lot of web server, lighttpd can directly protect the access at certain
pages or full folders by a password. This password protection is independent of
web application that is protected like this. It's append before any access to
the web pages and therefore of the application. The login/password couple can be
set manually or looked inside a database. We will see here how to link with
a LDAP database.&lt;/p&gt;
&lt;div class="section" id="configuration-of-ldap-authentication"&gt;
&lt;h2&gt;Configuration of LDAP authentication&lt;/h2&gt;
&lt;p&gt;To setup our configuration, we will modify (or create if absent) the file
&lt;code&gt;/etc/lighttpd/conf-available/05-auth.conf&lt;/code&gt;. First we need to configure
the authentication mechanism. Here, it will be LDAP. All reference to other
authentication mechanism such as &lt;code&gt;plain&lt;/code&gt; should be removed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;server.modules&lt;/span&gt;                &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_auth&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;auth.backend&lt;/span&gt;                 &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ldap&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;auth.backend.ldap.hostname&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;localhost&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;auth.backend.ldap.base-dn&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ou=People,dc=mydomain,dc=com&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;auth.backend.ldap.filter&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;(uid=$)&amp;quot;&lt;/span&gt;

&lt;span class="k"&gt;auth.backend.ldap.bind-dn&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;cn=user,dc=mydomain,dc=com&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;auth.backend.ldap.bind-pw&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;secret&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;auth.backend.ldap.hostname&lt;/code&gt;: server address&lt;/li&gt;
&lt;li&gt;&lt;code&gt;auth.backend.ldap.base-dn&lt;/code&gt;: tree were are the user saved&lt;/li&gt;
&lt;li&gt;&lt;code&gt;auth.backend.ldap.filter&lt;/code&gt;: filter to apply to obtain the users&lt;/li&gt;
&lt;li&gt;&lt;code&gt;auth.backend.ldap.bind-dn&lt;/code&gt;: login to use to bind to LDAP server&lt;/li&gt;
&lt;li&gt;&lt;code&gt;auth.backend.ldap.bind-pw&lt;/code&gt;: associated password&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;auth.backend.ldap.bind-dn&lt;/code&gt; and :code`auth.backend.ldap.bind-pw`
parameters are only necessary if the LDAP server require a specific account to
be able to access the different informations.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-of-folders-to-protect"&gt;
&lt;h2&gt;Configuration of folders to protect&lt;/h2&gt;
&lt;p&gt;Then we need to configure the folder that need to be protected by a password.
For example tout protect the contain of the two folder
&lt;code&gt;/repertoire_securise&lt;/code&gt;  and &lt;code&gt;/autre_repertoire_securise&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;auth.require&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/repertoire_securise/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;method&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;basic&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;realm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Password protected area 1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;require&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;valid-user&amp;quot;&lt;/span&gt;
                        &lt;span class="p"&gt;),&lt;/span&gt;
                  &lt;span class="s2"&gt;&amp;quot;/autre_repertoire_securise/&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;method&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;basic&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;realm&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Password protected area 2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;require&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;user=admin1|user=admin2&amp;quot;&lt;/span&gt;
                        &lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="p"&gt;),&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Other folders could be added to the list likewise.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;method&lt;/code&gt;: method type asked to the browser for authentication
&lt;code&gt;basic&lt;/code&gt;, &lt;code&gt;plain&lt;/code&gt;, &lt;code&gt;digest&lt;/code&gt; or &lt;code&gt;htdigest&lt;/code&gt;. LDAP
authentication in Debian only work with basic (various error for the others)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;realm&lt;/code&gt;: Message to display in the connexion dialog box.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;require&lt;/code&gt;: limitation to some user; a list of users separated by
&lt;code&gt;|&lt;/code&gt; or &lt;code&gt;valid-user&lt;/code&gt; for any user of the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-activation"&gt;
&lt;h2&gt;Configuration activation&lt;/h2&gt;
&lt;p&gt;Like all configuration of lighttpd, to activate it you need to create a symbolic
link to the configuration file in &lt;code&gt;/etc/lighttpd/conf-enable&lt;/code&gt; and to
restart lighttpd:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ln -s /etc/lighttpd/conf-available/05-auth.conf /etc/lighttpd/conf-enabled/
&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/lighttpd restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth"&gt;Module mod_auth - Using Authentication&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="lighttpd"></category><category term="Debian"></category><category term="LDAP"></category><category term="authentication"></category></entry><entry><title>PHP activation for lighttpd</title><link href="https://blog.tblein.eu/server/2016/PHP-activation-for-lighttpd/" rel="alternate"></link><published>2016-07-26T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-26:server/2016/PHP-activation-for-lighttpd/</id><summary type="html">&lt;p&gt;We will see how to let lighttpd execute PHP scripts and display their results
instead of their content.&lt;/p&gt;
&lt;div class="section" id="fastcgi-configuration-of-php5"&gt;
&lt;h2&gt;FastCGI configuration of PHP5&lt;/h2&gt;
&lt;p&gt;To execute PHP scripts, lighttpd can use the standardised interface CGI that is
used by web servers. It is an interface that allow easily the exchange between
a web server and a rending engine. Two version of this interface are available
in lighttpd, the classic one (CGI) and rapid one (FastCGI). We will use that
latest in our configuration.&lt;/p&gt;
&lt;p&gt;We will start by installing the CGI version of PHP5&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install php5-cgi
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The configuration take place in the
&lt;code&gt;/etc/lighttpd/conf-available/10-fastcgi.conf&lt;/code&gt; file. It should look like
the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;server.modules&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_fastcgi&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;fastcgi.server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;.php&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;
                     &lt;span class="s2"&gt;&amp;quot;bin-path&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/usr/bin/php-cgi&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="s2"&gt;&amp;quot;socket&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/tmp/php.socket&amp;quot;&lt;/span&gt;
                 &lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first line activate FastCGI. The rest associates the file that have
a &lt;code&gt;.php&lt;/code&gt; extension to PHP and render them using the CGI version of PHP5.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-activation"&gt;
&lt;h2&gt;Configuration activation&lt;/h2&gt;
&lt;p&gt;To activate the configuration you only need to create a symbolic link of that
file in &lt;code&gt;/etc/lighttpd/conf-enable&lt;/code&gt; folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A restart of lighttpd is then necessary to take the new configuration into account:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service lighttpd restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
</summary><category term="lighttpd"></category><category term="Debian"></category><category term="PHP"></category></entry><entry><title>Serving Mercurial repositories trough lighttpd</title><link href="https://blog.tblein.eu/server/2016/hg_lighttpd/" rel="alternate"></link><published>2016-07-23T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-23:server/2016/hg_lighttpd/</id><summary type="html">&lt;p&gt;We will describe here how to publish a group of Mercurial repositories on a web
server. It will allow us to access it with a traditional web browser. For that
we will link the web server to Mercurial with CGI. Once a repository is setup it
is very easy to add others.&lt;/p&gt;
&lt;div class="section" id="pre-requirements"&gt;
&lt;h2&gt;Pre-requirements&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;a functioning web server (here we will base on lighttpd for the instructions) see
[[linux:debian:webserveur]] for its installation.&lt;/li&gt;
&lt;li&gt;a classical installation of Mercurial.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;hgwebdir.cgi&lt;/code&gt; or &lt;code&gt;hgwebdir.fcgi&lt;/code&gt; script include with your
version of Mercurial. On a Debian install, you can find it in the
&lt;code&gt;/usr/share/doc/mercurial/examples/&lt;/code&gt; folder. It is also directly
available on Mercurial website: &lt;a class="reference external" href="http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi"&gt;hgwebdir.cgi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;In the case of use of the fastCGI version of the script
(&lt;code&gt;hgwebdir.fcgi&lt;/code&gt;) we should also install the &lt;code&gt;flup&lt;/code&gt; python module
(&lt;code&gt;python-flup&lt;/code&gt; pour Debian)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="repository-preparation"&gt;
&lt;h2&gt;Repository preparation&lt;/h2&gt;
&lt;p&gt;We will suppose that the repository is in the &lt;code&gt;/var/hg&lt;/code&gt; folder. First we
create the structure of the repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mkdir -p /var/hg/repos
&lt;span class="gp"&gt;#&lt;/span&gt; chown -R www-data:www-data /var/hg
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we create the configuration file of the repository
&lt;code&gt;/var/hg/hgweb.config&lt;/code&gt; which will allow us to take into account the
different mercurial repositories that will be in the &lt;code&gt;repos&lt;/code&gt; sub-folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[collections]&lt;/span&gt;
&lt;span class="na"&gt;repos/&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;repos/&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we need to place the &lt;code&gt;hgwebdir.fcgi&lt;/code&gt; script (in case of FastCGI use)
or &lt;code&gt;hgwebdir.cgi&lt;/code&gt; script (in case of CGI use) and to let executable by the
web server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mkdir /var/hg
&lt;span class="gp"&gt;#&lt;/span&gt; cp hgwebdir.fcgi /var/hg
&lt;span class="gp"&gt;#&lt;/span&gt; chown -R www-data:www-data /var/hg
&lt;span class="gp"&gt;#&lt;/span&gt; chmod +x /var/hg/hgwebdir.fcgi
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="lighttpd-configuration"&gt;
&lt;h2&gt;lighttpd configuration&lt;/h2&gt;
&lt;div class="section" id="in-a-sub-directory-of-the-site"&gt;
&lt;h3&gt;In a sub-directory of the site&lt;/h3&gt;
&lt;p&gt;According to lighttpd documentation, we need to edit the
&lt;code&gt;/etc/lighttpd/lighttpd.conf&lt;/code&gt; configuration file or a file which will be
include at lighttpd start up.  In Debian you can create a file (for example
&lt;code&gt;50-hg.conf&lt;/code&gt;) in the &lt;code&gt;/etc/lighttpd/available-conf/&lt;/code&gt; folder. Then
create a symlink to that file in &lt;code&gt;/etc/lighttpd/enable-conf/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;First you need to include the requiered modules:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;1 &lt;/span&gt; &lt;span class="k"&gt;server.modules&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_cgi&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;2 &lt;/span&gt; &lt;span class="k"&gt;server.modules&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_rewrite&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Second, you have to configure the address rewriting so the access to the
sub-directories of &lt;code&gt;hg&lt;/code&gt; should use &lt;code&gt;hgwebdir.fcgi&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;3 &lt;/span&gt; &lt;span class="k"&gt;url.rewrite-once&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="lineno"&gt;4 &lt;/span&gt;   &lt;span class="s2"&gt;&amp;quot;^/hg([/?].*)?$&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/hgwebdir.fcgi$1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="lineno"&gt;5 &lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, passing the correct parameters to the CGI script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;6 &lt;/span&gt; &lt;span class="nb"&gt;$HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;^/hgwebdir.fcgi([/?].*)?$&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;7 &lt;/span&gt;              &lt;span class="k"&gt;server.document-root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/var/hg/&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;8 &lt;/span&gt;              &lt;span class="k"&gt;cgi.assign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;.fcgi&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/usr/bin/python&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;9 &lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="as-a-virtual-host"&gt;
&lt;h2&gt;As a virtual host&lt;/h2&gt;
&lt;p&gt;In that case, the repositories will be accessible directly at the root of the
host through an address like &lt;cite&gt;hg.example.com&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;First, as before,  you need to include the requiered modules:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;1 &lt;/span&gt; &lt;span class="k"&gt;server.modules&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_cgi&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;2 &lt;/span&gt; &lt;span class="k"&gt;server.modules&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mod_rewrite&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Second, in that case we will configure that all access to &lt;cite&gt;hg.example.com&lt;/cite&gt; will
use the FastCGI script.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;3 &lt;/span&gt; &lt;span class="nb"&gt;$HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;host&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hg.example.com&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;4 &lt;/span&gt;     &lt;span class="k"&gt;server.document-root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/var/hg/&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;5 &lt;/span&gt;     &lt;span class="k"&gt;cgi.assign&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;.fcgi&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/usr/bin/python&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;6 &lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In that case, the addresses will show the name of the cript to use, that is
&lt;code&gt;hgwebdir.fcgi&lt;/code&gt;. As before we could can use the rewriting directive to
have sexier addresses, so without the name of the script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;7 &lt;/span&gt; &lt;span class="k"&gt;url.rewrite-once&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="lineno"&gt;8 &lt;/span&gt;     &lt;span class="s2"&gt;&amp;quot;^(/hgwebdir.fcgi/.*)$&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;$1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;^(/.*)$&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/hgwebdir.fcgi$1&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;9 &lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the Mercurial config file (&lt;code&gt;hgweb.config&lt;/code&gt;) you should also specify that
there is no prefix on the addresses:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[web]&lt;/span&gt;
&lt;span class="na"&gt;baseurl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="push-limitation"&gt;
&lt;h2&gt;Push limitation&lt;/h2&gt;
&lt;p&gt;The FastCGI/CGI script allow read but also write to the repositories. Therefore
to be able to limit the write (push) to only certian person two additionnal
modifications are requiered.&lt;/p&gt;
&lt;p&gt;First in the configuration file of the mercurial repository itself where you
want to put some limitation (&lt;code&gt;.hg/hgrc&lt;/code&gt;). In the web section, add the
names of the autorised users, or a star (&lt;code&gt;*&lt;/code&gt;) to allow everybody:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[web]&lt;/span&gt;
&lt;span class="na"&gt;allow_push&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;moimeme&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally in lighttpd configuration in the file where authentication are
specified:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;$HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;querystring&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;cmd=unbundle&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;auth.require&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;   &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;method&amp;quot;&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;basic&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;realm&amp;quot;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Mercuial Repo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="s2"&gt;&amp;quot;require&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;valid-user&amp;quot;&lt;/span&gt;
                        &lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;During a push it may failed with the following error:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;ssl required&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To allow pushes without SSL activated, just set it in the Mercurial
configuration file of the corresponding repository (&lt;code&gt;.hg/hgrc&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[web]&lt;/span&gt;
&lt;span class="na"&gt;push_ssl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;false&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://mercurial.selenic.com/wiki/HgWebDirStepByStep"&gt;Publishing Repositories with hgwebdir.cgi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="lighttpd"></category><category term="Mercurial"></category><category term="DVCS"></category></entry><entry><title>Syncthing on server</title><link href="https://blog.tblein.eu/server/2016/syncthing/" rel="alternate"></link><published>2016-08-20T21:15:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2016-07-10:server/2016/syncthing/</id><summary type="html">&lt;p&gt;&lt;a class="reference external" href="http://syncthing.net"&gt;Syncthing&lt;/a&gt; is peer to peer synchronisation software
than run on a lot of platform. To be able to synchronise two devices they need
to be both up at the same time. At the moment Syncthing is aimed to be run as
a single user. Therefore if we want that several users are using it on the same
machine several adjustement will be need.&lt;/p&gt;
&lt;div class="section" id="syncthing-installation"&gt;
&lt;h2&gt;Syncthing installation&lt;/h2&gt;
&lt;p&gt;The installation of Syncthing is well describe on their web site, and more
particularly for Debian/Ubuntu with a dedicated repository
&lt;a class="reference external" href="http://apt.syncthing.net/"&gt;http://apt.syncthing.net/&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-for-an-user"&gt;
&lt;h2&gt;Configuration for an user&lt;/h2&gt;
&lt;div class="section" id="first-launch-and-connection-to-the-interface"&gt;
&lt;h3&gt;First launch and connection to the interface&lt;/h3&gt;
&lt;p&gt;Setup a proxy to acces the web interface:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ssh -L 9090:127.0.0.1:8384 domaine.tld
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Launch synthing&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; syncthing
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Connect to the web interface  &lt;a class="reference external" href="http://localhost:9090"&gt;http://localhost:9090&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://docs.syncthing.net/users/firewall.html#remote-web-gui"&gt;https://docs.syncthing.net/users/firewall.html#remote-web-gui&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-of-syncthing"&gt;
&lt;h3&gt;Configuration of Syncthing&lt;/h3&gt;
&lt;p&gt;Change default configuration to allow multiple run of Syncthing (one per user).
The main parameters to change are the port that the instance of Syncthing will
use for first its web interface and second its connection.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Device Name: to have a idea of server and user&lt;/li&gt;
&lt;li&gt;Sync Protocol Listen Addresses: &lt;code&gt;tcp://:22001&lt;/code&gt; (by default &lt;code&gt;tcp://:22000&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;GUI Listen Addresses: &lt;code&gt;127.0.0.1:22002&lt;/code&gt; (by default &lt;code&gt;127.0.0.1:8384&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If on a server with direct connection to Internet deactivate &amp;quot;Enable NAT
traversal&amp;quot; and &amp;quot;Enable Relaying&amp;quot;.&lt;/p&gt;
&lt;p&gt;After restart you need to restart the ssh proxy with the new GUI Listen port:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ssh -L 9090:127.0.0.1:22002 domain.tld
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="firewall"&gt;
&lt;h3&gt;Firewall&lt;/h3&gt;
&lt;p&gt;You will need to open the firewall to allow entry of the synchronisation so open
TCP port corresponding to &amp;quot;Sync Protocol Listen Addresses&amp;quot;. If you want a direct
access to the web interface without the SSH proxy you could open also the
corresponding port.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="user-setup-for-automatic-start"&gt;
&lt;h2&gt;User setup for automatic start&lt;/h2&gt;
&lt;p&gt;With the help of systemd&lt;/p&gt;
&lt;p&gt;If it does not exist create the systemd user directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; mkdir -p ~/.config/systemd/user/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create a Syncthing service file to setup the service from the example on the
Syncthing github:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; wget -O ~/.config/systemd/user/syncthing.service &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="go"&gt;    https://github.com/syncthing/syncthing/raw/master/etc/linux-systemd/user/syncthing.service&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It should contain something like the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Syncthing - Open Source Continuous File Synchronization&lt;/span&gt;
&lt;span class="na"&gt;Documentation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;man:syncthing(1)&lt;/span&gt;
&lt;span class="na"&gt;After&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network.target&lt;/span&gt;
&lt;span class="na"&gt;Wants&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;syncthing-inotify.service&lt;/span&gt;

&lt;span class="k"&gt;[Service]&lt;/span&gt;
&lt;span class="na"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/bin/syncthing -no-browser -no-restart -logflags=0&lt;/span&gt;
&lt;span class="na"&gt;Restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;on-failure&lt;/span&gt;
&lt;span class="na"&gt;SuccessExitStatus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;3 4&lt;/span&gt;
&lt;span class="na"&gt;RestartForceExitStatus&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;3 4&lt;/span&gt;

&lt;span class="k"&gt;[Install]&lt;/span&gt;
&lt;span class="na"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;default.target&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Activate the script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; systemctl --user &lt;span class="nb"&gt;enable&lt;/span&gt; syncthing.service
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now you can start and stop Syncthing using systemd tools. Start Syncthing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; systemctl --user start syncthing.service
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To allow the start without any connexion of the user as root:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; loginctl enable-linger USER
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We then create a crontab entry to start Syncthing at reboot of the computer
(crontab -e):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;@reboot systemctl --user is-active syncthing.service &amp;amp;&amp;gt;/dev/null || systemctl --user start syncthing.service &amp;amp;&amp;gt; /dev/null
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We first test that the service is not running before starting it.
We can also test regurlaly that the service is running and if not start it:&lt;/p&gt;
&lt;p&gt;To do it every hours:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;0   *   *   *   * systemctl --user is-active syncthing.service &amp;amp;&amp;gt;/dev/null || systemctl --user start syncthing.service &amp;amp;&amp;gt; /dev/null
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://syncthing.net"&gt;Syncthing web site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.syncthing.net/users/autostart.html#using-systemd"&gt;Starting Syncthing automatically -- Using systemd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://docs.syncthing.net/users/firewall.html"&gt;Firewall Setup&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="reference external" href="https://lists.debian.org/debian-user/2015/10/msg00647.html"&gt;Re: Starting systemd user services on boot on a Debian server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="Debian"></category><category term="Syncthing"></category></entry><entry><title>Offline and caching of LDAP authentication</title><link href="https://blog.tblein.eu/server/2014/offline-and-caching-of-ldap-authentication/" rel="alternate"></link><published>2014-08-22T00:00:08+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2014-08-22:server/2014/offline-and-caching-of-ldap-authentication/</id><summary type="html">&lt;p&gt;Centralised authentication through LDAP is very useful. No matter the number of
machine that used it, the user have the same login and groups. When the user
change his password on one of the machine, the password is updated everywhere.
However in case of lack of connection with the LDAP server it is no more
possible to login. Here we will see how to configure &lt;a class="reference external" href="https://fedorahosted.org/sssd/"&gt;sssd&lt;/a&gt; to provide caching and offline support of
identity and authentication to the system.&lt;/p&gt;
&lt;p&gt;You will need to have a working LDAP server that is able to provide authentication.
On the client first install &lt;code&gt;sssd&lt;/code&gt; package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# apt-get install sssd&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It should also install &lt;code&gt;libpam-sss&lt;/code&gt; and &lt;code&gt;libnss-sss&lt;/code&gt; packages that
provide the binding for authentication and identity. Be sure to remove any other
caching server like &lt;code&gt;nscd&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;All the configuration is done in the &lt;code&gt;/etc/sssd/sssd.conf&lt;/code&gt; file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[sssd]&lt;/span&gt;
&lt;span class="na"&gt;config_file_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;2&lt;/span&gt;
&lt;span class="na"&gt;reconnection_retries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;3&lt;/span&gt;
&lt;span class="na"&gt;sbus_timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;30&lt;/span&gt;
&lt;span class="na"&gt;debug_level&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10&lt;/span&gt;

&lt;span class="na"&gt;services&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;nss, pam&lt;/span&gt;
&lt;span class="na"&gt;domains&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;EXAMPLE&lt;/span&gt;

&lt;span class="k"&gt;[nss]&lt;/span&gt;
&lt;span class="na"&gt;filter_groups&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;
&lt;span class="na"&gt;filter_users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;
&lt;span class="na"&gt;reconnection_retries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;3&lt;/span&gt;

&lt;span class="k"&gt;[pam]&lt;/span&gt;
&lt;span class="na"&gt;reconnection_retries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;3&lt;/span&gt;

&lt;span class="k"&gt;[domain/EXAMPLE]&lt;/span&gt;
&lt;span class="na"&gt;enumerate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;false&lt;/span&gt;
&lt;span class="na"&gt;cache_credentials&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;id_provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ldap&lt;/span&gt;
&lt;span class="na"&gt;auth_provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ldap&lt;/span&gt;
&lt;span class="na"&gt;chpass_provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ldap&lt;/span&gt;

&lt;span class="na"&gt;auth_provider&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ldap&lt;/span&gt;
&lt;span class="na"&gt;ldap_uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ldap://ldap.example.com/&lt;/span&gt;
&lt;span class="na"&gt;ldap_search_base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;dc=example,dc=com&lt;/span&gt;
&lt;span class="na"&gt;ldap_tls_reqcert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;never&lt;/span&gt;
&lt;span class="na"&gt;ldap_tls_cacert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/etc/ssl/certs/ca-certificates.crt&lt;/span&gt;
&lt;span class="na"&gt;ldap_default_bind_dn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;cn=admin,dc=example,dc=com&lt;/span&gt;
&lt;span class="na"&gt;ldap_default_authtok_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
&lt;span class="na"&gt;ldap_default_authtok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;xxxxxxxxx&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://fedorahosted.org/sssd/"&gt;SSSD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://sites.google.com/site/guenterbartsch/blog/debian7ldapauthenticationwithsssdtls"&gt;Debian 7 LDAP Authentication with SSSD, TLS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="https://wiki.samba.org/index.php/Local_user_management_and_authentication/sssd"&gt;Local user management and authentication/sssd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://people.skolelinux.org/pere/blog/Caching_password__user_and_group_on_a_roaming_Debian_laptop.html"&gt;Caching password, user and group on a roaming Debian laptop&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="SSSD"></category><category term="Debian"></category><category term="LDAP"></category><category term="caching"></category><category term="offline"></category></entry><entry><title>OpenVPN server on OpenWRT box</title><link href="https://blog.tblein.eu/server/2013/openvpn-server-on-openwrt-box/" rel="alternate"></link><published>2013-03-03T19:07:52+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2013-03-03:server/2013/openvpn-server-on-openwrt-box/</id><summary type="html">&lt;p&gt;While you are away from home it is sometime needed to access some files on the
home file server. To protect it it is not directly available from the web. We
will see here how to create a secure connexion to connect from the web on your
OpenWRT box to be able be like at home.&lt;/p&gt;
&lt;div class="section" id="installation-of-openvpn"&gt;
&lt;h2&gt;Installation of OpenVPN&lt;/h2&gt;
&lt;p&gt;For this we will install an OpenVPN server that will allow us to create
a Virtual Private Network. Just install the &lt;code&gt;openvpn&lt;/code&gt; package with the web
interface or the help of &lt;code&gt;opkg&lt;/code&gt; on command line.&lt;/p&gt;
&lt;p&gt;To work, OpenVPN need several keys and certificates. To handle it, OpenVPN
community provide a set of script to easily create all what is needed. It is
called &lt;code&gt;easy-rsa&lt;/code&gt;. You can install the &lt;code&gt;openvpn-easy-rsa&lt;/code&gt; package on
your OpenWRT box or &lt;a class="reference external" href="https://github.com/OpenVPN/easy-rsa"&gt;download easy-rsa from the web&lt;/a&gt; on your unix computer to save place on
OpenWRT.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="keys-and-certificates-creation"&gt;
&lt;h2&gt;Keys and certificates creation&lt;/h2&gt;
&lt;p&gt;Go inside the easy-rsa folder (&lt;code&gt;/etc/easy-rsa/&lt;/code&gt; on OpenWRT). First edit vars
file inside easy-rsa to fit your requirements:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;export KEY_COUNTRY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;FR&amp;quot;&lt;/span&gt;
&lt;span class="na"&gt;export KEY_PROVINCE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;FR&amp;quot;&lt;/span&gt;
&lt;span class="na"&gt;export KEY_CITY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Paris&amp;quot;&lt;/span&gt;
&lt;span class="na"&gt;export KEY_ORG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;At Home&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then creates the keys that are needed to signed all the key and certificates
generated:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;./clean-all
./build-ca
./build-dh
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Create the server key and certificate:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;./build-key-server my_server_name
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Copy on the OpenVPN folder of the OpenWRT box the server files that where
generated in the &lt;code&gt;keys&lt;/code&gt; folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;cp ca.crt ca.key dh1024.pem my_servername_.crt my_server_name.key /etc/openvpn/
&lt;/pre&gt;&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;ca.crt&lt;/code&gt; is the Certificate Authority (CA) certificate. The
corresponding key is used to sign all the certificates and keys and it all to
check the validity of provided certificate.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dh1024.pem&lt;/code&gt; contains the Diffie-Hellman parameters for the server side
of an SSL/TLS connection.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;my_server_name.key&lt;/code&gt; is the key used by the server to decrypt the
messages from the client.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;my_server_name.crt&lt;/code&gt; is the certificate that the server provide to the
client to allow it to crypt the conection. It is signed by the CA to prove
that it is coming from the server.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then for each user create the corresponding key and certificate:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;./build-key user1
./build-key user2
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Give to each user the generated files: ca.crt, user_name.key user.name.crt. They
are the only needed files for them&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="open-the-correct-port-in-your-firewall"&gt;
&lt;h2&gt;Open the correct port in your firewall&lt;/h2&gt;
&lt;p&gt;You must open the 1194 port in the firewall to all the OpenVPN connection from
the WAN. You can do it through the web interface or by editing the
&lt;code&gt;/etc/config/firewall&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;rule&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;target&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ACCEPT&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;dest_port&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1194&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;src&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;wan&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;proto&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;tcpudp&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;family&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ipv4&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Do not forget to reload the firewall rules if you modify it on command line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;/etc/init.d/firewall restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="server-configuration"&gt;
&lt;h2&gt;Server configuration&lt;/h2&gt;
&lt;p&gt;The configuration of OpenVPN is set in &lt;code&gt;/etc/config/openvpn&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;openvpn&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;lan&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;enable&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;port&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1194&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;proto&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;udp&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;dev&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;tap0&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ca&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/etc/openvpn/ca.crt&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;cert&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/etc/openvpn/server.crt&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;key&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/etc/openvpn/server.key&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;dh&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/etc/openvpn/dh1024.pem&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ifconfig_pool_persist&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/tmp/ipp.txt&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;keepalive&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;10 120&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;comp_lzo&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;persist_key&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;persist_tun&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;1&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;status&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;/tmp/openvpn-status.log&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;verb&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;3&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;server_bridge&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;192.168.1.1 255.255.255.0 192.168.1.200 192.168.1.219&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This configuration will allow the client to be part of the network handled by
the OpenWRT box. It will grab a IP i the range 192.168.1.200 to 192.168.1.219.&lt;/p&gt;
&lt;p&gt;To prevent that a local client to have an IP in that range we can modify the
&lt;code&gt;/etc/config/dhcp&lt;/code&gt; file to restrict the attribution of the IP in an non
overlapping range. Modify the lan section of that file like following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;dhcp&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;lan&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;interface&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;lan&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ignore&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;0&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;start&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;50&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;limit&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;150&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The local client will only have an IP in the range of 192.168.1.50 to 192.168.1.150.
Restart &lt;code&gt;dnsmasq&lt;/code&gt; to take it into account:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;/etc/init.d/dnsmasq restart
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can start the server with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;/etc/init.d/openvpn start
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To have it start automaticaly when the OpenWT box starts just run the following
command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;/etc/init.d/openvpn &lt;span class="nb"&gt;enable&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="bridging-of-the-interfaces"&gt;
&lt;h2&gt;Bridging of the interfaces&lt;/h2&gt;
&lt;p&gt;To be able to link the OpenVPN tunnel, we need to bridge the interfaces. It an
be done in the web interface or in the &lt;code&gt;/etc/config/network&lt;/code&gt; file. In the
&lt;code&gt;lan&lt;/code&gt; section add &lt;code&gt;tap0&lt;/code&gt; to the &lt;code&gt;ifname&lt;/code&gt; option:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;interface&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;lan&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;type&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;bridge&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;proto&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;static&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ipaddr&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;192.168.1.1&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;netmask&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;255.255.255.0&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;_orig_ifname&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;eth0.0 wl0&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;_orig_bridge&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;true&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;ifname&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;eth0.0 tap0&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="client-configuration"&gt;
&lt;h2&gt;Client configuration&lt;/h2&gt;
&lt;p&gt;Now that the OpenVPN server is running we just have to connect to it.  In
addition to the personal key and certificate and of the CA certificate the user
will need also a configuration file.  They should look like the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# OpenVPN on bridge OpenWRT&lt;/span&gt;

client
tls-client
&lt;span class="c1"&gt;# Which device to use&lt;/span&gt;
dev tap
&lt;span class="c1"&gt;# Which protocol&lt;/span&gt;
proto udp
&lt;span class="c1"&gt;# The OpenWRT external address&lt;/span&gt;
remote x.x.x.x 1194

resolv-retry infinite
nobind

persist-tun
persist-key

&lt;span class="c1"&gt;# The different used keys&lt;/span&gt;
ca ca.crt
cert user1.crt
key user1.key

&lt;span class="c1"&gt;# Use compression&lt;/span&gt;
comp-lzo
&lt;span class="p"&gt;;&lt;/span&gt; verb 3
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now you should be able to connect to your home network from the web.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="source"&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.openwrt.org/doc/howto/vpn.openvpn"&gt;Easy OpenVPN server setup guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="OpenWRT"></category><category term="OpenVPN"></category><category term="VPN"></category></entry><entry><title>RTSP through OpenWRT</title><link href="https://blog.tblein.eu/server/2013/rtsp-through-openwrt/" rel="alternate"></link><published>2013-03-03T17:36:49+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2013-03-03:server/2013/rtsp-through-openwrt/</id><summary type="html">&lt;p&gt;The French ISP Free provide TV over DSL. Some of the channels could be directly
seen on a computer through the RTSP protocol. However it is not something that
is working nicely through a home switch that is just behind the FreeBox DSL
router like an OpenWRT running box.&lt;/p&gt;
&lt;p&gt;Several solution exist on the net however major part of them required static
port forwarding linked with configuration of VLC (The recommended client). Here
we will see how to allow it without all this strong and static configuration
with the help of two kernel module that will track the RTSP connexion, open the
correct port in the firewall and routes the packet to the VLC client. These two
modules are &lt;code&gt;ip_nat_rtsp&lt;/code&gt; et &lt;code&gt;ip_conntrack_rtsp&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;To process only the &lt;code&gt;kmod-ipt-nathelper-extra&lt;/code&gt; package need to be
installed on the OpenWRT box. Do either through the web interface or through ssh
with the help of &lt;code&gt;opkg&lt;/code&gt;. After installation check that the two requiered
modules are loaded with the two following commands on the OpenWRT box:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;insmod ip_conntrack_rtsp
insmod ip_nat_rtsp
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If its answer that &lt;code&gt;insmod: a module named ip_nat_rtsp already exists&lt;/code&gt;, it
means that the module is already loaded.&lt;/p&gt;
&lt;p&gt;Now you just have to launch you preferred player and start watching.&lt;/p&gt;
&lt;div class="section" id="source"&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.boulaire.com/2009/03/openwrt-et-free-multiposte/"&gt;Openwrt et Free multiposte&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="OpenWRT"></category><category term="RTSP"></category><category term="Free.fr"></category><category term="multiposte"></category></entry><entry><title>OpenWRT wifi toggle</title><link href="https://blog.tblein.eu/server/2013/OpenWRT_wifi_toggle/" rel="alternate"></link><published>2013-03-03T17:01:46+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2013-03-03:server/2013/OpenWRT_wifi_toggle/</id><summary type="html">&lt;p&gt;The WRT54GL router has two buttons: one reset button and one called
&amp;quot;SecureEasySetup&amp;quot; or SES. After OpenWRT installation this two button do not
served. We will see how to give a role to the SES one to toggle the wifi on and
off.&lt;/p&gt;
&lt;div class="section" id="wifi-toggle-script"&gt;
&lt;h2&gt;Wifi toggle script&lt;/h2&gt;
&lt;p&gt;First we will create a script that allow us to change the wifi status. It will
activate the wifi when it is not and inactivate it otherwise. In addition it
will change the WLAN LED status according to the wifi status.&lt;/p&gt;
&lt;p&gt;For that, we will create the file &lt;code&gt;/sbin/woggle&lt;/code&gt; (for wifi toogle), that
contain:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;uci get wireless.@wifi-device&lt;span class="o"&gt;[&lt;/span&gt;0&lt;span class="o"&gt;]&lt;/span&gt;.disabled&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; in
   1&lt;span class="o"&gt;)&lt;/span&gt; uci &lt;span class="nb"&gt;set&lt;/span&gt; wireless.@wifi-device&lt;span class="o"&gt;[&lt;/span&gt;0&lt;span class="o"&gt;]&lt;/span&gt;.disabled&lt;span class="o"&gt;=&lt;/span&gt;0
      wifi
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &amp;gt; /proc/diag/led/ses_white
   &lt;span class="p"&gt;;;&lt;/span&gt;
   *&lt;span class="o"&gt;)&lt;/span&gt; uci &lt;span class="nb"&gt;set&lt;/span&gt; wireless.@wifi-device&lt;span class="o"&gt;[&lt;/span&gt;0&lt;span class="o"&gt;]&lt;/span&gt;.disabled&lt;span class="o"&gt;=&lt;/span&gt;1
      wifi
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &amp;gt; /proc/diag/led/ses_white
      &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &amp;gt; /proc/diag/led/wlan
   &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The script first grabs the wifi status (&lt;code&gt;uci get
wireless.&amp;#64;wifi-device[0].disabled&lt;/code&gt;). If it deactivated (ie equal to &lt;code&gt;1&lt;/code&gt;),
it actives it and switch on the LED of the SES button. Otherwise it deactivates
the wifi switch off the LED of SES button and let the WLAN LED blink once.&lt;/p&gt;
&lt;p&gt;After creation do not forget to set it executable with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; chmod +x /sbin/woggle
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To change the wifi status and test the command, you can run the script with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /sbin/woggle
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="link-with-the-ses-button"&gt;
&lt;h2&gt;Link with the SES button&lt;/h2&gt;
&lt;p&gt;Now that e have the script to toggle the wifi, we need to link it with the SES
button. Like this it will be execute each time the SES button is pressed.&lt;/p&gt;
&lt;p&gt;It is handle by the hotplug events. For this it is needed top create the
&lt;code&gt;button&lt;/code&gt; directory in the &lt;code&gt;/etc/hotplug.d&lt;/code&gt; directory. Then in that
newly created directory create a script with a name like the following
&lt;code&gt;01-radio-toggle&lt;/code&gt; contenting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$BUTTON&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ses&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$ACTION&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;pressed&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
  &lt;span class="o"&gt;(&lt;/span&gt; sleep 1&lt;span class="p"&gt;;&lt;/span&gt; /sbin/woggle &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now to activate or deactivate the wifi you only need to press the SES button.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.openwrt.org/doc/howto/wifitoggle"&gt;Wifi Toggle&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="Wifi"></category><category term="OpenWRT"></category><category term="WRT54GL"></category></entry><entry><title>LDAP authentication</title><link href="https://blog.tblein.eu/server/2012/ldap-authentication/" rel="alternate"></link><published>2012-09-07T00:49:16+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2012-09-07:server/2012/ldap-authentication/</id><summary type="html">&lt;p&gt;How to add ldap authentication to Debian server. It suppose that a running ldap
server  is running and that the ldap tree is filled correctly with account
informations.&lt;/p&gt;
&lt;div class="section" id="libnss-ldapd-installation"&gt;
&lt;h2&gt;libnss-ldapd installation&lt;/h2&gt;
&lt;p&gt;The client need the &lt;cite&gt;libnss-ldapd&lt;/cite&gt; package that is a fork of the historical
&lt;cite&gt;libnss-ldap&lt;/cite&gt; for better efficiency&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# apt-get install libnss-ldapd&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For the configuration it ask the following information:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;URI of the LDAP server. better as an IP to prevent any DNS resolution problem&lt;/li&gt;
&lt;li&gt;The root base where to look for the information (DN)&lt;/li&gt;
&lt;li&gt;The name services to configure: aliases, ethers, group, hosts, netgroup,
networks, passwd, protocols, rpc,services, shadow. for LDAP authentication
group, passwd and shadow should be selected.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="set-identification-credential-for-ldap-connexion"&gt;
&lt;h2&gt;Set identification credential for LDAP connexion&lt;/h2&gt;
&lt;p&gt;If the connexion to the LDAP server need an authentication you can specify it in
the &lt;code&gt;/etc/nslcd.conf&lt;/code&gt; file by uncommenting and adjusting the following
variables:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;binddn cn=nss,dc=example,dc=com
bindpw my_password
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After modification, restart nslcd service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# /etc/init.d/nslcd restart&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="testing"&gt;
&lt;h2&gt;Testing&lt;/h2&gt;
&lt;p&gt;To test if it is working, we need to ask for information that are store locally
and in the LDAP server. To get information about account we need to use the
&lt;code&gt;getent&lt;/code&gt; command followed by the name of the database we want to retrieve.&lt;/p&gt;
&lt;p&gt;For example to retrieve all the content of the &lt;code&gt;passwd&lt;/code&gt; database we use
the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ getent passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
&lt;span class="o"&gt;[&lt;/span&gt;...&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It should show entries that are present on the local database but also in the
LDAP directory.&lt;/p&gt;
&lt;p&gt;We can also limit to a particular entry, like root account:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# getent passwd root&lt;/span&gt;
root:x:0:0:root:/root:/bin/bash
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And here for root group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# getent group root&lt;/span&gt;
root:x:0:admin
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="home-directory-creation"&gt;
&lt;h2&gt;Home directory creation&lt;/h2&gt;
&lt;p&gt;The creation of the home directory is normally done when creating the user.
However for LDAP user they might not have been created on the current system and
therefore did not have any home directory. If you want that it is created
automatically at the connexion of the user if it does not exist you need to edit
the &lt;code&gt;/etc/pam.d/common-session&lt;/code&gt; file and add at the end the following
line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;session required        pam_mkhomedir.so skel=/etc/skel
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="references"&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.debian.org/LDAP/NSS"&gt;LDAP/NSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://arthurdejong.org/nss-pam-ldapd/setup"&gt;nss-pam-ld:how to set up LDAP authentication&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="authentication"></category><category term="LDAP"></category><category term="Debian"></category></entry><entry><title>New server setup</title><link href="https://blog.tblein.eu/server/2012/New-server-setup/" rel="alternate"></link><published>2012-09-07T00:16:15+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2012-09-07:server/2012/New-server-setup/</id><summary type="html">&lt;p&gt;Small process when we get a new installed with more eye-candy staff and
security.&lt;/p&gt;
&lt;div class="section" id="core-configuration"&gt;
&lt;h2&gt;Core configuration&lt;/h2&gt;
&lt;div class="section" id="locales-configuration"&gt;
&lt;h3&gt;Locales configuration&lt;/h3&gt;
&lt;p&gt;To setup the appropates locales on the system: the one that will be available
for the users.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; dpkg-reconfigure locales
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Select the local according to the language you want and the different encodings.
The more languages encoding you will selected the more time it will need to
generate them and the more disk space it will use.&lt;/p&gt;
&lt;p&gt;For example, to get French messages select the locales starting by &lt;code&gt;fr_FR&lt;/code&gt;
(French from France) for all encoding. The best encoding on Unix system is
UTF-8. On the second screen select the default language and encoding that will
be used by the system for example &lt;code&gt;fr_FR.UTF-8&lt;/code&gt;, to get message in French
by default.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="bash-configuration"&gt;
&lt;h3&gt;Bash configuration&lt;/h3&gt;
&lt;p&gt;The creation of a new user take the default configuration files that are present
in the &lt;code&gt;/etc/skel/&lt;/code&gt; folder.  However, by default the root user do not get
these files. Therefore to get a better bash shell for root with color prompt and
auto-completion we have to copy the &lt;code&gt;.bashrc&lt;/code&gt; manually:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; cp /etc/skel/.bashrc &lt;span class="nv"&gt;$HOME&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By default the bash auto-completion is activated in that file.&lt;/p&gt;
&lt;p&gt;To activate the color prompt uncomment the line 39:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;39 &lt;/span&gt; &lt;span class="c1"&gt;#force_color_prompt=yes&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;to get&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;39 &lt;/span&gt; &lt;span class="nv"&gt;force_color_prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;yes
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Some commands can use color. To use it by default some alias could be activated
in the lines 78 and following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; -x /usr/bin/dircolors &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;test&lt;/span&gt; -r ~/.dircolors &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;dircolors -b ~/.dircolors&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;dircolors -b&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;ls&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ls --color=auto&amp;#39;&lt;/span&gt;
    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;dir --color=auto&amp;#39;&lt;/span&gt;
    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;vdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;vdir --color=auto&amp;#39;&lt;/span&gt;

    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;grep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;grep --color=auto&amp;#39;&lt;/span&gt;
    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;fgrep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;fgrep --color=auto&amp;#39;&lt;/span&gt;
    &lt;span class="nb"&gt;alias&lt;/span&gt; &lt;span class="nv"&gt;egrep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;egrep --color=auto&amp;#39;&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Logout and login again to get it active, or source it to get active in the current shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# source $HOME/.bashrc&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="set-a-alias-address-for-root-account"&gt;
&lt;h3&gt;Set a alias address for root account&lt;/h3&gt;
&lt;p&gt;By default all system email are send to the root user. However, to avoid uneeded
root login it is a godd idea to redirect this email to an other account or
address. For that we need to modify &lt;code&gt;/etc/aliases&lt;/code&gt; so it contain the
following line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;root:&lt;/span&gt; &lt;span class="err"&gt;nom@domain.com&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;All email send to root will be send to this address.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="increase-the-security-of-the-system"&gt;
&lt;h2&gt;Increase the security of the system&lt;/h2&gt;
&lt;div class="section" id="system-upgrade"&gt;
&lt;h3&gt;System upgrade&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude update
&lt;span class="gp"&gt;#&lt;/span&gt; aptitude dist-upgrade
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To receive by email automatically available system upgrade, you need to install
&lt;code&gt;apticron&lt;/code&gt; package&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install apticron
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The message of possible upgrade will be send by email on a daily basis to root
by default&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="fail2ban-installation"&gt;
&lt;h3&gt;fail2ban installation&lt;/h3&gt;
&lt;p&gt;fail2ban is a daemon that is monitoring connexion attempt and blacklist
temporarily IP addresses after a certain amount of failed connexion from this
IP. This prevent brute force attack s, that try all possible password to enter
the system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install fail2ban
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To configure it you have to edit the &lt;code&gt;/etc/fail2ban/fail.conf&lt;/code&gt; file.
Several modules are available for fail2ban and to activate them you need to go
to the end of the configuration file (around the line 74). Each module is called
a &lt;code&gt;JAIL&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Each &lt;code&gt;JAIL&lt;/code&gt; is setup the same way, like for example for &lt;code&gt;ssh&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[ssh]&lt;/span&gt;
&lt;span class="na"&gt;enabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;port&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ssh&lt;/span&gt;
&lt;span class="na"&gt;filter&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;sshd&lt;/span&gt;
&lt;span class="na"&gt;logpath&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/var/log/auth.log&lt;/span&gt;
&lt;span class="na"&gt;maxretry&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;6&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Its name is in between &lt;code&gt;[]&lt;/code&gt;, and the option &lt;code&gt;enable&lt;/code&gt; is set to true
to activate it. The port that have to be monitored is set with the &lt;code&gt;port&lt;/code&gt;
option, like the log file (&lt;code&gt;logpath&lt;/code&gt;) and the filter to use to interpret
it (&lt;code&gt;filter&lt;/code&gt;). Finally the number of error that is allowed before an IP
ban (&lt;code&gt;maxretry&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;By default the &lt;code&gt;ssh&lt;/code&gt; JAIL is activated. The &lt;code&gt;pam-generic&lt;/code&gt; JAIL allow
to block the user after error on the PAM module. The &lt;code&gt;ssh-ddos&lt;/code&gt; JAIL to
protect against deny of service attacks.&lt;/p&gt;
&lt;p&gt;To take into account the new configuration you need to restart the service with
the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service fail2ban restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="rkhunter-installation"&gt;
&lt;h3&gt;rkhunter installation&lt;/h3&gt;
&lt;p&gt;It is a software that search for rootkit by searching for modification of main
programs compared to safe stat and signature and to identify already known
rootkits.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install rkhunter
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="debsecan-installation"&gt;
&lt;h3&gt;debsecan installation&lt;/h3&gt;
&lt;p&gt;Check for security alerts on the web in relation with the system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install debsecan
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To configure it run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; dpkg-reconfigure debsecan
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Select the correct distribution, so the alert will be in relation to it.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.enyo.de/fw/software/debsecan/"&gt;debsecan web site&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="firewall-configuration-with-ferm"&gt;
&lt;h2&gt;Firewall configuration with ferm&lt;/h2&gt;
&lt;p&gt;See the corresponding article about &lt;a class="reference external" href="https://blog.tblein.eu/server/2016/Easy-firewall-with-ferm/"&gt;ferm&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="ssh-connexion-limitation"&gt;
&lt;h2&gt;SSH connexion limitation&lt;/h2&gt;
&lt;div class="alert alert-danger"&gt;
Do not deactivate the SSH connexion for the &lt;code&gt;root&lt;/code&gt; user without any
other account on the system: you will not be able to connect to the server
anymore.&lt;/div&gt;
&lt;p&gt;First create a user (&lt;code&gt;admin&lt;/code&gt; in this example) that will be able to connect as
&lt;code&gt;root&lt;/code&gt; after the deactivation of the SSH connexion for &lt;code&gt;root&lt;/code&gt; user.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; adduser admin
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When configured, the SSH connexion for &lt;code&gt;root&lt;/code&gt; user can be deactivated in
the &lt;cite&gt;/etc/ssh/sshd_config&lt;/cite&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;26 &lt;/span&gt; &lt;span class="err"&gt;PermitRootLogin&lt;/span&gt; &lt;span class="err"&gt;no&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restart SSH server to take it into account.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/ssh restart
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="limitation-of-the-su-command-only-to-certain-users"&gt;
&lt;h3&gt;Limitation of the su command only to certain users&lt;/h3&gt;
&lt;div class="alert alert-danger"&gt;
It is highly suggested to keep a connected root console on the server until the
configuration is working et to confirmed that we can become root before
closing it. In case of error, it might prevent any connexion as root.&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;su&lt;/code&gt; command allow to change user in a console to execute a program.
The main case is the switch to &lt;code&gt;root&lt;/code&gt; for administration tasks. However,
it could be nice to limit this possibility to certain user. By default
&lt;code&gt;su&lt;/code&gt; can be executed by any user, assuming he knows the password of the
targeted user. It is possible to limit this possibility to a particular group by
modifying the PAM configuration file of su (&lt;code&gt;/etc/pam.d/su&lt;/code&gt;). The
following should be uncommented:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;15 &lt;/span&gt; &lt;span class="err"&gt;auth&lt;/span&gt;       &lt;span class="err"&gt;required&lt;/span&gt;   &lt;span class="err"&gt;pam_wheel.so&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;By default, the user should belong to the &lt;code&gt;root&lt;/code&gt; group to be able to use
&lt;code&gt;su&lt;/code&gt;. Historically, the super-user group is called &lt;code&gt;wheel&lt;/code&gt; therefore
the name of the PAM module (see [[!wikipedia Wheel_(Unix_term)]] for more info).
It is possible to change the &lt;code&gt;wheel&lt;/code&gt; group to consider by adding the
&lt;code&gt;group=group_name&lt;/code&gt; option to the command. Therefore to set the &lt;code&gt;adm&lt;/code&gt;
group as &lt;code&gt;wheel&lt;/code&gt; group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;15 &lt;/span&gt; &lt;span class="na"&gt;auth       required   pam_wheel.so group&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;adm&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then you just have to add the user you want to allow to connect as root in the
correct group. For example to add the &lt;code&gt;admin&lt;/code&gt; user to the &lt;code&gt;root&lt;/code&gt;
group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; adduser admin root
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://howto.landure.fr/gnu-linux/debian-4-0-etch/complements-a-linstallation-dune-debian-4-0-etch"&gt;Compléments à l'installation d'une Debian 4.0 Etch ou 5.0 Lenny&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.debian.org/doc/manuals/debian-reference/ch-tune.fr.html#s-wheel"&gt;Pourquoi GNU su ne supporte pas le groupe wheel&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="security"></category><category term="setup"></category><category term="Debian"></category></entry><entry><title>Resource management links</title><link href="https://blog.tblein.eu/server/2012/resource-management-links/" rel="alternate"></link><published>2012-07-06T14:02:58+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2012-07-06:server/2012/resource-management-links/</id><summary type="html">&lt;p&gt;Description:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The Simple Linux Utility for Resource Management (SLURM) is an open source,
fault-tolerant, and highly scalable  cluster management and job scheduling
system for large and small Linux clusters. SLURM requires no kernel
modifications for its operation and is relatively self-contained. As a cluster
resource manager, SLURM has three key functions. First, it allocates exclusive
and/or non-exclusive access to resources (compute nodes) to users for some
duration of time so they can perform work. Second, it provides a framework for
starting, executing, and monitoring work (normally a parallel job) on the set
of allocated nodes. Finally, it arbitrates contention for resources by
managing a queue of pending work.&lt;/p&gt;
&lt;p class="attribution"&gt;&amp;mdash;&lt;a class="reference external" href="http://www.schedmd.com/slurmdocs/slurm.html"&gt;SLURM: A Highly Scalable Resource Manager&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.schedmd.com/slurmdocs/slurm.html"&gt;SLURM: A Highly Scalable Resource Manager&lt;/a&gt; Official SLURM website&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.hpc2n.umu.se/batchsystem/examples_scripts"&gt;Example job submission files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</summary><category term="SLURM"></category><category term="links"></category></entry><entry><title>Installation of a CAcert certificate for lighttpd</title><link href="https://blog.tblein.eu/server/2012/installation-of-a-cacert-certificate-for-lighttpd/" rel="alternate"></link><published>2012-05-01T22:35:45+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2012-05-01:server/2012/installation-of-a-cacert-certificate-for-lighttpd/</id><summary type="html">&lt;p&gt;Here we will see how to set up a X.509 certificate signed by &lt;a class="reference external" href="http://www.cacert.org"&gt;CAcert&lt;/a&gt; on lighttpd web server&lt;/p&gt;
&lt;div class="section" id="tls-ssl"&gt;
&lt;h2&gt;TLS/SSL&lt;/h2&gt;
&lt;p&gt;[[!wikipedia Transport_Layer_Security]] best known as TLS/SSL is a cryptographic
protocol use on Internet to encrypt communications. It using both asymmetric
encryption for key exchange and symmetric encryption for the rest of the
communication. Therefore, one server private key and the corresponding server
certificate are needed.&lt;/p&gt;
&lt;p&gt;The confidentiality of the exchanges is mainly based on the certificate. To be
sure that we get the server certificate from the correct server it is be signed
by some [[!wikipedia Certificate_Authority]]. The [[!wikipedia
Certificate_Authority]] is often a third party that is recognize by the two
actors. The most known are [[!wikipedia VeriSign]], [[!wikipedia GoDaddy]] and
[[!wikipedia Comodo]]. However, they are quite expensives.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="get-a-signed-certificate-by-cacert"&gt;
&lt;h2&gt;Get a signed certificate by CAcert&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.cacert.org"&gt;CAcert&lt;/a&gt; is a community driven, Certificate Authority
that issues certificates to the public for free. To get a signed certificate
just register on the web site.&lt;/p&gt;
&lt;p&gt;You will need to install the &lt;code&gt;ssl-cert&lt;/code&gt; and &lt;code&gt;ca-certificates&lt;/code&gt; to be
able to generate the server private key and a certificate signing request (CSR).
To generate CAcert provide a small shell script &lt;a class="reference external" href="http://svn.cacert.org/CAcert/Software/CSRGenerator/csr"&gt;csr&lt;/a&gt;.  After downloading
it just run it and answer the questions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ csr.sh
Private Key and Certificate Signing Request Generator
This script was designed to suit the request format needed by
the CAcert Certificate Authority. www.CAcert.org

Short Hostname &lt;span class="o"&gt;(&lt;/span&gt;ie. imap big_srv www&lt;span class="o"&gt;)&lt;/span&gt;: www
FQDN/CommonName &lt;span class="o"&gt;(&lt;/span&gt;ie. www.example.com&lt;span class="o"&gt;)&lt;/span&gt; : *.example.com
Type SubjectAltNames &lt;span class="k"&gt;for&lt;/span&gt; the certificate, one per line. Enter a blank line to finish
SubjectAltName: DNS:*.example.com
SubjectAltName: DNS:
Running OpenSSL...
Generating a &lt;span class="m"&gt;2048&lt;/span&gt; bit RSA private key
......+++
...............................................................+++
writing new private key to &lt;span class="s1"&gt;&amp;#39;/home/user/www_privatekey.pem&amp;#39;&lt;/span&gt;
-----
Copy the following Certificate Request and paste into CAcert website to obtain a Certificate.
When you receive your certificate, you &lt;span class="s1"&gt;&amp;#39;should&amp;#39;&lt;/span&gt; name it something like www_server.pem

-----BEGIN CERTIFICATE REQUEST-----
MIIBzTCCATYCAQAwgYwxCzAJBgNVBAYTAmdiMQ8wDQYDVQQIEwZMb25kb24xDzAN
BgNVBAcTBkxvbmRvbjEZMBcGA1UEChMQU3BhY2VTdXJmZXIgTHRkLjEZMBcGA1UE
AxMQd3d3LnNwYWNlcmVnLmNvbTElMCMGCSqGSIb3DQEJARYWd2VibWFzdGVyQHNw
YWNlcmVnLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAywfuXnd348ot
iAcZ4RHFc509ImCTagKaNkiQ4xyijbPYP7H0UQ5iXqvojSIcbUOVhExqwqyqjCPm
7ZpON3IXktIcKAwPFvoqKkHuqTa8KMnZTSY8P7QILYHFd2Sd1l1arCrWv8HWb+qM
RHVTlviBaLAHQxnz28qKkYN09K0fw5cCAwEAAaAAMA0GCSqGSIb3DQEBBAUAA4GB
AFMgp2KkHQXMC1JbZf3AkIz7mrl4X21cRusTfd8ec3RuMZexGy76jMGFyPWVM69R
Fvpfiic8h28HrHube7pEPFpdUSj2cR4OZCAg5uqzN/ESwc4CtLzej7pWoDPpc/kv
hiJ/eGOxINKd39kCuzIS6zrvb2ihJth7jcmokezmrwjQ
-----END CERTIFICATE REQUEST-----

The Certificate request is also available in /home/user/www_csr.pem
The Private Key is stored in /home/user/www_privatekey.pem
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Submit your CSR to &lt;a class="reference external" href="www.cacert.org"&gt;CAcert web site&lt;/a&gt; and save the resulting
signed private key in a file in the &lt;code&gt;/etc/ssl/private&lt;/code&gt; folder:
&lt;code&gt;server_certificate.pem&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;-----BEGIN CERTIFICATE-----
MIIErjCCApagAwIBAgIDC65yMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv
b3QgQ0ExHjAcBdHA6Ly93d3cuY2FjZXgNVBAsTFWh0J0Lm9yZzEiMCAGA1UEAxMZ
Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y
dEBjYWNlcnQub3JnM5MMDUwMTEXDTEyMTAyODE5TcxOFoB4XDTEyMTcxOFowFjEU
MBIGA1UEAxQLKi50YmxlaW4uZXUwggEiMwAwggEKA0GCSqGSIb3DQEBAQUAA4IBD
Ip4P+pzo1lvNbCCorGUozI3Bh9f/hshftTb2P6Y0KAlja81jtK3fXz2am86NJ037
AoIBAQDDVCgRg/nWoZmE990WD5AxC0NvVQgOmCvuP84JSoDgzIgGbNiCspkNm3uB
gYw+B0JD7d0luyvrXu4nf5UG3lBeB0NUoYKNTfMYsBrwugNyukEegq7VMmzLo21t
FoDnUn/Dg6lEE08g5MXzTNqSQzL/60jrI7/A2mYdtOb3Pg20+GONN326kbeKK6EA
kaaN8R3tPVY1PNTG9HPAe8scIF3V3FXkqj6E2GuLcQZmfK9OmFdPzy9VvZ5RFGoA
abTFXA6xCT6Apfrpd04e0Fh18Dq+SvdmWS8Y6sBXUxL50GHTSBSMAggSgIDWujxi
OE2OdPEQjCUR9TOSVGBVT6JFzRkLXZ+8GJWELyQisUZDtcXN8Msy2wpdovSLf2QL
rTx0rBgl3DhoRmfPab4Vq8OZb+zlGf9armskX4JFWNejF9ZcIt65myv7P8yfucjT
tcbZRuw0DINpAxqDdK4B25RE6GF7AgMBAAGjgaEwgZ4wDAYDVR0TAQH/BAIwADA0
BgkqhkiG9w0BAQUFAAOCAgEAn3X9Xj4D+hNY0Gla5Q5fMtOOXhT253VtjubpdEcs
BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEGCWCGSAGG+EIEAQYKKwYBBAGC
NwoDAzALBgNVHQ8EBAMCBaAwMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdo
dHRwOi8vb2NzcC5jYWNlcnQub3JnLzAWBgNVHREEDzANggsqLnRibGVpbi5ldTAN
8ZBJBLxzNi5ipDDNRvJQKkd09tZ1JHqE+AdKLBpqi29exQp9AMEgZGw+ljibK3UD
ZV8oBRW1icLVNXunG2jY6hTWmP11baaAnTnELyknCtDYgH5t2KPDwpiLBQS5UNuc
+tFldPrs9kIUhCy/t//vKrlKiqg7JZuoEFhVgmjPpoQbHRwyHuiSW6IKqmwKWdA5
Kp0mVUUqfFDU+C+RjvKpeEtS3j7r3MDAo083KzJerI0YsOFxqJRZ3++mzOqY7Teu
uulk4GvV6re2GsuWWXKMPhK8Sz5jGEVYK7Wf7iGWTgwDJuicyRkjBHWFkfYlrL7V
/KZnak4lLEAOXYhwNnqHfrUiaDtvWhZXkYfrC4tRMSHRhKg9Kub1x3cGnhb/+Duq
GZI0M17BoQZZmPUGqpxm2NLyizwlH+hKyomKpBcX35kxeQLk3ilHuyb58zc4AWgg
&lt;span class="nv"&gt;NOI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
-----END CERTIFICATE-----
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To check its validity run &lt;code&gt;openssl&lt;/code&gt; command with the action &lt;code&gt;verify&lt;/code&gt;
on it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ openssl verify server_certificat.pem
server_certificat.pem: OK
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You should get &lt;code&gt;OK&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="inclusion-of-the-certificate-to-be-handle-by-lighttpd"&gt;
&lt;h2&gt;Inclusion of the certificate to be handle by lighttpd&lt;/h2&gt;
&lt;p&gt;To be able to encrypt data with lighttpd the server certificate, the server
private key and the certificate authority certificate should be given to
lighttpd. The private key and the server certificate should be combined in one
file with a command like the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# cat /etc/ssl/private/server_privatekey.pem /etc/ssl/certs/server_certificate.pem \&lt;/span&gt;
   &amp;gt; /etc/ssl/private/lighttpd.pem
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then change the access right of this file to readable only by the owner and the
group owner and writable by the owner. This very important to set it up like
this since anybody who have access to this file will be able to decrypt all the
encrypt traffic of the server.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# chgrp www-data /etc/ssl/private/lighttpd.pem&lt;/span&gt;
&lt;span class="c1"&gt;# chmod 640 /etc/ssl/private/lighttpd.pem&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then you need to configure lighttpd for example in
&lt;code&gt;/etc/lighttpd/conf-enabled/10-ssl.conf&lt;/code&gt; on Debian to take into account
the certificate:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nb"&gt;$SERVER&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;socket&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;0.0.0.0:443&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;ssl.engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;enable&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;ssl.ca-file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/usr/share/ca-certificates/cacert.org/cacert.org.crt&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;ssl.pemfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/etc/ssl/private/lighttpd.pem&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;ssl.cipher-list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;ssl.honor-cipher-order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;enable&amp;quot;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;ssl.ca-file&lt;/code&gt; entry specify the certificate authority certificate and
&lt;code&gt;ssl.pemfile&lt;/code&gt; the server privat key and certificate file.&lt;/p&gt;
&lt;p&gt;You just need to restart lighttpd and your certificate should be available.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# /etc/init.d/lighttpd restart&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="resources"&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.flexion.org/linux/cacert-certificate/"&gt;Get a Certificate from CACert&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.cacert.org"&gt;CAcert&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.system-linux.eu/index.php?post/2009/12/04/Certificat-x509-pour-votre-Apache"&gt;Certificat x509 pour votre Apache&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="CAcert"></category><category term="lighttpd"></category><category term="Debian"></category></entry><entry><title>Installation d'un serveur OpenVPN</title><link href="https://blog.tblein.eu/server/2011/Installation-of-an-OpenVPN-server/index-fr.html" rel="alternate"></link><published>2011-09-05T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2011-09-05:server/2011/Installation-of-an-OpenVPN-server/index-fr.html</id><summary type="html">&lt;div class="section" id="installation-du-serveur"&gt;
&lt;h2&gt;Installation du serveur&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install openvpn
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="generation-des-certificats-et-cles"&gt;
&lt;h2&gt;Génération des certificats et clés&lt;/h2&gt;
&lt;p&gt;Tout se passe dans le repertoire
&lt;code&gt;/usr/share/doc/openvpn/examples/easy-rsa/2.0/&lt;/code&gt; Pour s'y rendre:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /usr/share/doc/openvpn/examples/easy-rsa/2.0/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ensuite il faut modifier les valeurs du fichier &lt;code&gt;vars&lt;/code&gt; en accord avec nos
paramètres avec notamment:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;64 &lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KEY_COUNTRY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;FR&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;65 &lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KEY_PROVINCE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;66 &lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KEY_CITY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Petaouchnok&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;67 &lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KEY_ORG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Ma Boite&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;68 &lt;/span&gt; &lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;KEY_EMAIL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ma@maboite.fr&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;une fois le fichier &lt;code&gt;vars&lt;/code&gt; complété il faut initialisé les variables
à l'aide de la commande:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;source&lt;/span&gt; vars
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Une remise à zéro de la génération de certificat dans le sous dossier
&lt;code&gt;keys&lt;/code&gt; s'effectue à l'aide de la commande suivante :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ./clean-all
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="generation-du-certificat-et-de-la-cle-de-lautorite-de-certification-ca"&gt;
&lt;h3&gt;Génération du certificat et de la clé de l’autorité de certification (CA)&lt;/h3&gt;
&lt;p&gt;Il s'agit du certificat principal du serveur qui va être utilisé par tous les
nœud pour la signature des différents certificats et clés. Ainsi en utilisant la
clé le certificat va pouvoir contrôler la provenance des certificats présentés
par les clients.  Pour les générer :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ./build-ca
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il suffit de répondre par défaut au questions qui ont été pré-remplies par le
fichier &lt;code&gt;vars&lt;/code&gt;. Seul l'entrée &lt;code&gt;Common Name&lt;/code&gt; n'est pas remplie. Il
s'agit du nom du serveur. Le certificat est créé dans le fichier
&lt;code&gt;keys/ca.crt&lt;/code&gt; et la clé correspondantes dans le fichier
&lt;code&gt;keys/ca.key&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="generation-du-certificat-et-de-la-cle-du-serveur"&gt;
&lt;h3&gt;Génération du certificat et de la clé du serveur&lt;/h3&gt;
&lt;p&gt;Il s'agit du certificat et de la clé qui permettront d'identifier le serveur. Le
script suivant permet de générer la clé &lt;code&gt;NomDuServeur.key&lt;/code&gt; et le
certificat &lt;code&gt;NomDuServeur.crt&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ./build-key-server NomDuServeur
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Vers la fin de ce script il est demandé un mot de passe. Si un mot de passe est
entré, à chaque démarrage du serveur OpenVPN il faudra entrer ce mot de passe.
Dans le cas contraire il n'y en aura pas besoin, mais une personne possédant la
clé pourra l'utiliser sans contrainte.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="generation-du-certificat-et-de-la-cle-pour-chaque-client"&gt;
&lt;h3&gt;Génération du certificat et de la clé pour chaque client&lt;/h3&gt;
&lt;p&gt;Pour les clients un script comparable existe. Ainsi pour obtenir le certificat
et la clé pour un client &lt;code&gt;lambda&lt;/code&gt; :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ./build-key lambda
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;La clé &lt;code&gt;keys/lambda.key&lt;/code&gt; et le certificat &lt;code&gt;keys/lambda.crt&lt;/code&gt; sont
ainsi créer. Comme précédemment pour la clé du serveur concernant le mot de
passe. Il faut répéter cette procédure pour chaque client différents.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="creation-du-parametre-diffie-hellman"&gt;
&lt;h3&gt;Création du paramètre Diffie Hellman&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ./build-dh
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;qui va créer le fichier &lt;code&gt;keys/dh1024.pem&lt;/code&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-du-serveur-openvpn"&gt;
&lt;h2&gt;Configuration du serveur OpenVPN&lt;/h2&gt;
&lt;p&gt;Il faut déplacer les certificats et la clé créés pour le serveur dans le
répertoire principale de OpenVPN (code:&lt;cite&gt;/etc/openvpn/&lt;/cite&gt;), a savoir le certificat
et la clé de l’autorité de certification (code:&lt;cite&gt;ca.crt&lt;/cite&gt; et &lt;code&gt;ca.key&lt;/code&gt;), le
certificat et la clé spécifiques du serveur (code:&lt;cite&gt;NomDuServeur.crt&lt;/cite&gt; et
&lt;code&gt;NomDuServeur.key&lt;/code&gt;) et le fichier du paramettre de Diffie Hellman
(code:&lt;cite&gt;dh1024.pem&lt;/cite&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/ca.crt /etc/openvpn/
&lt;span class="gp"&gt;#&lt;/span&gt; cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/ca.key /etc/openvpn/
&lt;span class="gp"&gt;#&lt;/span&gt; cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/NomDuServeur.crt /etc/openvpn/
&lt;span class="gp"&gt;#&lt;/span&gt; cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/NomDuServeur.key /etc/openvpn/
&lt;span class="gp"&gt;#&lt;/span&gt; cp /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/dh1024.pem /etc/openvpn/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Une fois les différents fichier en place il faut créer un fichier de
configuration pour le serveur. Pour cela le plus simple est de partir à partir
du fichier d'exemple contenu dans&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /usr/share/doc/openvpn/examples/sample-config-files/
&lt;span class="gp"&gt;#&lt;/span&gt; gunzip server.conf.gz
&lt;span class="gp"&gt;#&lt;/span&gt; cp server.conf /etc/openvpn/
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-du-serveur-comme-point-d-acces"&gt;
&lt;h2&gt;Configuration du serveur comme point d'accés&lt;/h2&gt;
&lt;div class="section" id="configuration-du-pare-feux-ferm"&gt;
&lt;h3&gt;Configuration du pare-feux ferm&lt;/h3&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Mise en place du NAT des adresses:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="n"&gt;POSTROUTING&lt;/span&gt; &lt;span class="n"&gt;saddr&lt;/span&gt; &lt;span class="mf"&gt;10.8.0.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;255.255.255.0&lt;/span&gt; &lt;span class="n"&gt;MASQUERADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Autoriser les connexions depuis l'interface du vpn dans la table filter et la chaine INPUT :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;interface&lt;/span&gt; &lt;span class="n"&gt;tun0&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Autoriser le transfert de paquets venant du vpn chaine FORWARD :&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;interface&lt;/span&gt; &lt;span class="n"&gt;tun0&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="autoriser-le-forward-ipv4"&gt;
&lt;h3&gt;Autoriser le forward IPv4&lt;/h3&gt;
&lt;p&gt;De manière temporaire:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &amp;gt; /proc/sys/net/ipv4/ip_forward
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;De manière permanente en définisant dans le fichier &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; l'option &lt;code&gt;net.ipv4.ip_forward&lt;/code&gt; à 1:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;net.ipv4.ip_forward&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.coagul.org/spip.php?article422"&gt;Installation OpenVPN 2.01 sur une Debian Etch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://howto.landure.fr/gnu-linux/debian-4-0-etch/installer-et-configurer-openvpn-sur-debian-4-0-etch"&gt;Installer et configurer OpenVPN sur Debian 4.0 Etch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.cacert.org/wiki/OpenWRT"&gt;OpenWRT sur CACert Wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.frogdev.info/openvpn.php"&gt;OPENVPN sur frogdev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.lea-linux.org/documentations/index.php/Point_d'accès_sécurisé_par_OpenVPN"&gt;Point d'accès sécurisé par OpenVPN sur Léa-Linux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="VPN"></category><category term="Debian"></category><category term="OpenVPN"></category></entry><entry><title>Installation d'un serveur pptpd</title><link href="https://blog.tblein.eu/server/2011/Installation-of-a-pptpd-server/index-fr.html" rel="alternate"></link><published>2011-08-30T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2011-08-30:server/2011/Installation-of-a-pptpd-server/index-fr.html</id><summary type="html">&lt;p&gt;PTP est un protocole de tunnel de point à point permettant de créer des réseaux
privés [[wp&amp;gt;Point-to-Point_Tunneling_Protocol]]. Conçut par Microsoft, il est
moins robuste que les solutions VPN récentes comme OpenVPN, IPSec mais
a l'avantage d'être implémenté d'office dans Windows et est plus facilement
accessible que les autres solution de VPN sur certains appareils (HP TouchPad).
Nous alons voir ici comme le mettre en place sur un serveur Debian (Squeeze) en
utilisant le serveur poptop (paquet &lt;code&gt;pptpd&lt;/code&gt;).&lt;/p&gt;
&lt;div class="section" id="installation-et-configuration-du-serveur"&gt;
&lt;h2&gt;Installation et configuration du serveur&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install pptpd
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="adresses"&gt;
&lt;h3&gt;Adresses&lt;/h3&gt;
&lt;p&gt;La configuration a lieu dans le fichier &lt;code&gt;/etc/pptpd.conf&lt;/code&gt;. Vous devez
y préciser l'adresse IP privé du serveur ainsi que la plage d'adresse IP
utilisées par les clients. Par exemple pour un serveur ayant pour adresse privé
10.8.1.1 et des clients entre les adresses IP 10.8.1.10 à 10.8.1.20:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;localip&lt;/span&gt; &lt;span class="err"&gt;10.8.1.1&lt;/span&gt;
&lt;span class="err"&gt;remoteip&lt;/span&gt; &lt;span class="err"&gt;10.8.1.10-20&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="utilisateurs"&gt;
&lt;h3&gt;Utilisateurs&lt;/h3&gt;
&lt;p&gt;Pour se connecter au serveur les utilisateurs doivent spécifié un nom
d'utilisateur et un mot de passe. Ils sont spécifiés dans le fichier
&lt;code&gt;/etc/ppp/chap-secrets&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour cela pour et pour chaque utilisateur il suffit d'ajouter une ligne comme la
suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;client&lt;/span&gt;    &lt;span class="err"&gt;server&lt;/span&gt;  &lt;span class="err"&gt;secret&lt;/span&gt;          &lt;span class="err"&gt;IP&lt;/span&gt; &lt;span class="err"&gt;addresses&lt;/span&gt;
&lt;span class="err"&gt;monlogin&lt;/span&gt;    &lt;span class="err"&gt;*&lt;/span&gt;     &lt;span class="err"&gt;monmotdepasse&lt;/span&gt;       &lt;span class="err"&gt;*&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="regles-du-pare-feux"&gt;
&lt;h2&gt;Règles du pare feux&lt;/h2&gt;
&lt;p&gt;Le VPN ppptp utilise le port 1723 il faut donc l'ouvrir pour pouvoir s'y
connecter. Ainsi avec &lt;code&gt;ferm&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="n"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="n"&gt;INPUT&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;proto&lt;/span&gt; &lt;span class="n"&gt;tcp&lt;/span&gt; &lt;span class="n"&gt;dport&lt;/span&gt; &lt;span class="mi"&gt;1723&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Une fois les utilisateurs connectés et si vous considérez que vos utilisateurs
sont sures vous pouvez ouvrir les ports en provenance du VPN:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="n"&gt;filter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="n"&gt;INPUT&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;interface&lt;/span&gt; &lt;span class="n"&gt;ppp0&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="acces-internet-a-travers-le-vpn"&gt;
&lt;h2&gt;Accès internet à travers le VPN&lt;/h2&gt;
&lt;p&gt;Cela permet aux utilisateurs du VPN d'accéder au reste du réseau et internet
à travers le VPN.&lt;/p&gt;
&lt;div class="section" id="activation-du-transfert-des-paquets-ip-au-niveau-du-noyau"&gt;
&lt;h3&gt;Activation du transfert des paquets IP au niveau du noyau&lt;/h3&gt;
&lt;p&gt;Cela s'effectue via la commande suivante&amp;nbsp;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &amp;gt; /proc/sys/net/ipv4/ip_forward
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour le rendre permanent il suffit de décommenter
dans le fichier &lt;code&gt;/etc/sysctl.conf&lt;/code&gt; la ligne&amp;nbsp;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;net.ipv4.ip_forward&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="id1"&gt;
&lt;h3&gt;Règles du pare-feux&lt;/h3&gt;
&lt;p&gt;Dans un premier temps il faut autoriser le transfert de paquets IP en provenance
du VPN. Par exemple avec ferm:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="n"&gt;FORWARD&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;interface&lt;/span&gt; &lt;span class="n"&gt;ppp0&lt;/span&gt; &lt;span class="n"&gt;ACCEPT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ain si la translation d'adresse en provenance des adresses du réseau VPN. Par exemple avec ferm&amp;nbsp;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="n"&gt;nat&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;chain&lt;/span&gt; &lt;span class="n"&gt;POSTROUTING&lt;/span&gt; &lt;span class="n"&gt;saddr&lt;/span&gt; &lt;span class="mf"&gt;10.8.1.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;255.255.255.0&lt;/span&gt; &lt;span class="n"&gt;MASQUERADE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="mise-en-place-d-un-serveur-dns"&gt;
&lt;h2&gt;Mise en place d'un serveur DNS&lt;/h2&gt;
&lt;p&gt;Lors des connexions internet le serveur DNS est primordial pour associer les URL
avec les adresses IP correspondantes. Afin que les clients puissent utiliser un
service DNS facilement il est possible d'installer le cache de DNS
&lt;code&gt;dnsmasq&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install dnsmasq
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-d-un-client-sous-linux"&gt;
&lt;h2&gt;Configuration d'un client sous Linux&lt;/h2&gt;
&lt;p&gt;Pour se connecter au VPN depuis Linux il suffit d'installer le paquet
&lt;code&gt;pptp-linux&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install pptp-linux
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;La configuration se fait dans les fichiers du répertoire &lt;code&gt;/etc/ppp&lt;/code&gt;. Les
mots de passe et accès sont spécifiés dans le même fichier que pour le serveur
à savoir &lt;code&gt;/etc/ppp/chap-secrets&lt;/code&gt;. Ainsi comme pour l'utilisateur du VPN
précédent:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;client    server  secret          IP addresses
monlogin   PPTP   monmotdepasse       *
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ensuite pour facilité la création du tunnel il faut créer un fichier
(&lt;code&gt;mon_vpn&lt;/code&gt; dans notre exemple) dans le répertoire &lt;code&gt;/etc/ppp/peers/&lt;/code&gt;
contenant par exemple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;pty &lt;span class="s2"&gt;&amp;quot;pptp mon_vpn.example.net --nolaunchpppd&amp;quot;&lt;/span&gt;
name tblein
remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
ipparam mon_vpn
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On initialise le tunnel via la commande:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; pon mon_vpn
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour l'arrêter :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; poff mon_vpn
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Afin que les connexions passe par le tunnel il suffit de modifier les routes par
défaut.&lt;/p&gt;
&lt;p&gt;TODO&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://blog.sumostyle.net/robg/2010/01/01/setting-up-pptpd-on-debian-lenny/"&gt;Setting up pptpd on debian (lenny)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://pptpclient.sourceforge.net/howto-debian.phtml"&gt;PPTP Client Debian HOWTO&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="Debian"></category><category term="PTP"></category><category term="VPN"></category><category term="pptpd"></category></entry><entry><title>Installation d'un serveur SMTP avec Postfix</title><link href="https://blog.tblein.eu/server/2011/SMTP-server-installation-with-Postfix/index-fr.html" rel="alternate"></link><published>2011-01-20T00:00:00+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2011-01-20:server/2011/SMTP-server-installation-with-Postfix/index-fr.html</id><summary type="html">&lt;p&gt;Installation du serveur SMTP Postfix pour recevoir et envoyer des email sur un
serveur.&lt;/p&gt;
&lt;div class="section" id="installation-et-configuration-de-base"&gt;
&lt;h2&gt;Installation et configuration de base&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install postfix
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Répondre aux question en accord avec la configuration. Les descriptions
associées à chaque paramètre sont explicites. Par défault c'est le format
mailbox qui est utilisé pour stocké les messages. Pour changer en Maildir il
suffit d'ajouter la ligne suivante au fichier de configuration principal de
postfix &lt;code&gt;/etc/postfix/main.cf&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;home_mailbox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;Maildir/&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dans cet exemple les mails seront sauvegarder sous le format Maildir (c'est
à dire un message par fichier) dans le dossier Maildir du répertoire personnel
de l'utilisateur.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="securisation"&gt;
&lt;h2&gt;Sécurisation&lt;/h2&gt;
&lt;p&gt;Plusieurs astuces de configuration permettent de bloquer une partie messages non
solicités via des règles simples à ajouter à son fichier
&lt;code&gt;/etc/postfix/main.cf&lt;/code&gt;:&lt;/p&gt;
&lt;p&gt;Ne pas vérifier si l'utilisateur existe sur le système:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;disable_vrfy_command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;N'accepter les messages entrant que d'un serveur s'autentifiant complètement:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;smtpd_helo_required&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;yes&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restriction de receptions via analyse des informations de l'expéditeur:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;smtpd_sender_restrictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&lt;/span&gt;
&lt;span class="s"&gt;    permit_mynetworks,            # Autorise les envois depuis le même domaine&lt;/span&gt;
&lt;span class="s"&gt;    permit_sasl_authenticated,    # Autorise les envois si authentifié&lt;/span&gt;
&lt;span class="s"&gt;    reject_non_fqdn_sender,       # Rejete si l&amp;#39;expéditeur ne fourni pas un nom completement qualifié&lt;/span&gt;
&lt;span class="s"&gt;    reject_unknown_sender_domain, # Rejete si cela provient d&amp;#39;un nom de domaine inconnue&lt;/span&gt;
&lt;span class="s"&gt;    permit                        # Sinon autorise&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Restriction sur le réseau d'envoie du mail&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;smtp_client_restrictions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&lt;/span&gt;
&lt;span class="s"&gt;    permit_mynetworks,                                # Autorise les envois depuis le même domaine&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client blackholes.easynet.nl,          # Différentes Blacklists&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client cbl.abuseat.org,&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client proxies.blackholes.wirehub.net,&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client bl.spamcop.net,&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client sbl.spamhaus.org,&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client dnsbl.njabl.org,&lt;/span&gt;
&lt;span class="s"&gt;    reject_rbl_client list.dsbl.org,&lt;/span&gt;
&lt;span class="s"&gt;    permit&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Un redémarage du service postfix est nécessaire pour prendre en compte la nouvelle configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service postfix restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
</summary><category term="mail"></category><category term="Postfix"></category><category term="SMTP"></category></entry><entry><title>bdb_equality_candidates: (uid) not indexed</title><link href="https://blog.tblein.eu/server/2010/bdb_equality_candidates---uid--not-indexed/index-fr.html" rel="alternate"></link><published>2010-03-09T00:00:00+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2010-03-09:server/2010/bdb_equality_candidates---uid--not-indexed/index-fr.html</id><summary type="html">&lt;p&gt;Il arrive que dans les fichier journaux (syslog) des messages comme suivant apparaissent:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;Mar  9 14:56:13 kimsufi slapd[2187]: &amp;lt;= bdb_equality_candidates: (uid) not indexed&lt;/span&gt;
&lt;span class="go"&gt;Mar  9 14:59:20 kimsufi slapd[23640]: &amp;lt;= bdb_equality_candidates: (gidNumber) not indexed&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Comme le dit le message il s'agit d'erreur parce que certains attributs ne sont
pas indexés. Pour les indexer, il suffit de le demander à OpenLDAP en modifiant
le fichier &lt;code&gt;/etc/ldap/slapd.conf&lt;/code&gt; pour ajouter les index manquant:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;index&lt;/span&gt; &lt;span class="err"&gt;ou,cn,sn,uid&lt;/span&gt;  &lt;span class="err"&gt;pres,sub,eq&lt;/span&gt;
&lt;span class="err"&gt;index&lt;/span&gt; &lt;span class="err"&gt;uidNumber,gidNumber,memberUid&lt;/span&gt;     &lt;span class="err"&gt;eq,pres&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dans un second temps il faut construire ces index. Pour ceci il convient dans un
premier temps d'arréter le service OpenLDAP:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/slapd stop
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;De génerer les index avec la commande &lt;code&gt;slapdindex&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; slapindex
&lt;span class="go"&gt;  WARNING!&lt;/span&gt;
&lt;span class="go"&gt;  Runnig as root!&lt;/span&gt;
&lt;span class="go"&gt;  There&amp;#39;s a fair chance slapd will fail to start.&lt;/span&gt;
&lt;span class="go"&gt;  Check file permissions!&lt;/span&gt;
&lt;span class="go"&gt;  /etc/ldap/slapd.conf: line 128: rootdn is always granted unlimited privileges.&lt;/span&gt;
&lt;span class="go"&gt;  /etc/ldap/slapd.conf: line 145: rootdn is always granted unlimited privileges.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il convient ensuite de donner les droits à l'utilisateur openldap de lire et
écrire les fichiers de la base:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; chown openldap:openldap /var/lib/ldap/*
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Puis dans un dernier temps de redémaré le service OpenLDAP:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/slapd start
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les messages d'erreurs devraient disparaitres des fichiers de log. Si d'autres
index manquent, les rajouter en fonction.&lt;/p&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://help.ubuntu.com/community/OpenLDAP-SambaPDC-OrgInfo-Posix"&gt;OpenLDAP-SambaPDC-OrgInfo-Posix&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="bdb_equality_candidates"></category><category term="log"></category><category term="LDAP"></category></entry><entry><title>Installation d'un dépôt subversion</title><link href="https://blog.tblein.eu/server/2010/Installation-of-a-SVN-repository/index-fr.html" rel="alternate"></link><published>2010-02-11T00:00:00+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2010-02-11:server/2010/Installation-of-a-SVN-repository/index-fr.html</id><summary type="html">&lt;div class="section" id="installation-de-subversion"&gt;
&lt;h2&gt;Installation de subversion&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; apt-get install subversion subversion-tools
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="acces-distant-au-depot-via-svnserve"&gt;
&lt;h2&gt;Accès distant au dépot via &lt;code&gt;svnserve&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;svnserve est un serveur inclut dans subversion. Aucun paquet supplémentaire n'est necessaire.
Ajout d'un utilisateur &lt;code&gt;svn&lt;/code&gt; pour lancer &lt;code&gt;svnserve&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; adduser svn --system
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les dépôts seront stockés dans le dossier &lt;code&gt;/home/svn/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour permettre l'accès au dépôt il faut démarrer le serveur svnserve. Pour cela
le petit script &lt;code&gt;svn&lt;/code&gt; suivant placé dans &lt;code&gt;/etc/init.d&lt;/code&gt; va permettre de le
démarer comme n'importe quel autre serveur.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt; 1 &lt;/span&gt; &lt;span class="c1"&gt;#!/bin/sh&lt;/span&gt;
&lt;span class="lineno"&gt; 2 &lt;/span&gt; &lt;span class="c1"&gt;# /etc/init.d/svn: set up the svnserve server&lt;/span&gt;
&lt;span class="lineno"&gt; 3 &lt;/span&gt; &lt;span class="c1"&gt;### BEGIN INIT INFO&lt;/span&gt;
&lt;span class="lineno"&gt; 4 &lt;/span&gt; &lt;span class="c1"&gt;# Provides:          svn&lt;/span&gt;
&lt;span class="lineno"&gt; 5 &lt;/span&gt; &lt;span class="c1"&gt;# Required-Start:    $local_fs&lt;/span&gt;
&lt;span class="lineno"&gt; 6 &lt;/span&gt; &lt;span class="c1"&gt;# Required-Stop:     $local_fs&lt;/span&gt;
&lt;span class="lineno"&gt; 7 &lt;/span&gt; &lt;span class="c1"&gt;# Should-Start:      $named&lt;/span&gt;
&lt;span class="lineno"&gt; 8 &lt;/span&gt; &lt;span class="c1"&gt;# Should-Stop:       $named&lt;/span&gt;
&lt;span class="lineno"&gt; 9 &lt;/span&gt; &lt;span class="c1"&gt;# Default-Start:     S&lt;/span&gt;
&lt;span class="lineno"&gt;10 &lt;/span&gt; &lt;span class="c1"&gt;# Default-Stop:&lt;/span&gt;
&lt;span class="lineno"&gt;11 &lt;/span&gt; &lt;span class="c1"&gt;### END INIT INFO&lt;/span&gt;
&lt;span class="lineno"&gt;12 &lt;/span&gt;
&lt;span class="lineno"&gt;13 &lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt; -e
&lt;span class="lineno"&gt;14 &lt;/span&gt;
&lt;span class="lineno"&gt;15 &lt;/span&gt; &lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/bin:/usr/bin:/sbin:/usr/sbin
&lt;span class="lineno"&gt;16 &lt;/span&gt; &lt;span class="nv"&gt;SOCKET_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/.X11-unix
&lt;span class="lineno"&gt;17 &lt;/span&gt; &lt;span class="nv"&gt;ICE_DIR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/.ICE-unix
&lt;span class="lineno"&gt;18 &lt;/span&gt;
&lt;span class="lineno"&gt;19 &lt;/span&gt; . /lib/lsb/init-functions
&lt;span class="lineno"&gt;20 &lt;/span&gt; . /etc/default/rcS
&lt;span class="lineno"&gt;21 &lt;/span&gt;
&lt;span class="lineno"&gt;22 &lt;/span&gt; &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; in
&lt;span class="lineno"&gt;23 &lt;/span&gt; start&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;24 &lt;/span&gt;       log_daemon_msg &lt;span class="s2"&gt;&amp;quot;Starting svnserve daemon&amp;quot;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;svnserve&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;25 &lt;/span&gt;       start-stop-daemon --start --quiet --background --pidfile /var/run/svnserve.pid --make-pidfile --exec &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="lineno"&gt;26 &lt;/span&gt;       /usr/bin/svnserve -c svn:svn -- -d --listen-port &lt;span class="m"&gt;3690&lt;/span&gt; -r /home/svn
&lt;span class="lineno"&gt;27 &lt;/span&gt;       log_end_msg &lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="lineno"&gt;28 &lt;/span&gt;       &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="lineno"&gt;29 &lt;/span&gt; stop&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;30 &lt;/span&gt;       log_daemon_msg &lt;span class="s2"&gt;&amp;quot;Stopping svnserve daemon&amp;quot;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;svnserve&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;31 &lt;/span&gt;       killall svnserve
&lt;span class="lineno"&gt;32 &lt;/span&gt;       log_end_msg &lt;span class="nv"&gt;$?&lt;/span&gt;
&lt;span class="lineno"&gt;33 &lt;/span&gt;       rm -f /var/run/svnserve.pid
&lt;span class="lineno"&gt;34 &lt;/span&gt;       &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="lineno"&gt;35 &lt;/span&gt;
&lt;span class="lineno"&gt;36 &lt;/span&gt; *&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;37 &lt;/span&gt;       &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Usage: /etc/init.d/rsync {start|stop}&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;38 &lt;/span&gt;       &lt;span class="nb"&gt;exit&lt;/span&gt; 1
&lt;span class="lineno"&gt;39 &lt;/span&gt;       &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="lineno"&gt;40 &lt;/span&gt; &lt;span class="k"&gt;esac&lt;/span&gt;
&lt;span class="lineno"&gt;41 &lt;/span&gt; &lt;span class="nb"&gt;exit&lt;/span&gt; 0
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour arrêter le serveur la commande &lt;code&gt;start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/svnserve.pid&lt;/code&gt; aurait du suffir, cependant il y a  une petite erreur lors de la création du fichier pid de l'application ce qui ne permet pas d'arrêter svnserve.&lt;/p&gt;
&lt;p&gt;Le fichier &lt;code&gt;/etc/init.d/svn&lt;/code&gt; doit être executable.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; chmod +x /etc/init.d/svn
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour démarer svnserve:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service svn start
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="ajout-d-un-depot"&gt;
&lt;h2&gt;Ajout d'un dépôt&lt;/h2&gt;
&lt;p&gt;La commande &lt;code&gt;svnadmin&lt;/code&gt; permet d'administrer les dépôts subversion.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /home/svn
&lt;span class="gp"&gt;#&lt;/span&gt; svnadmin create nouveau_depot
&lt;span class="gp"&gt;#&lt;/span&gt; chown -R svn:svn nouveau_depot
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="configuration-du-depot-pour-svnserve"&gt;
&lt;h3&gt;Configuration du dépôt pour svnserve&lt;/h3&gt;
&lt;p&gt;Le fichier &lt;code&gt;/home/svn/nouveau_depot/conf/svnserve.conf&lt;/code&gt; permet de
configurer les options d'accès du dépôts via SVNserve.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[general]&lt;/span&gt;
&lt;span class="na"&gt;anon-access&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
&lt;span class="na"&gt;auth-access&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;write&lt;/span&gt;
&lt;span class="na"&gt;password-db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;passwd&lt;/span&gt;
&lt;span class="na"&gt;realm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;Mon dépôt SVN&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les autorisation de lecture/écriture sur le dépôt sont définies via les
variables &lt;code&gt;anon-access&lt;/code&gt; pour les utilisateurs non authentifiés et
&lt;code&gt;auth-access&lt;/code&gt; pour les utilisateurs authentifiés. Trois valeurs peuvent
être utilisées:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;none&lt;/code&gt;: aucun accès .&lt;/li&gt;
&lt;li&gt;&lt;code&gt;read&lt;/code&gt;: accès en lecture seule&lt;/li&gt;
&lt;li&gt;&lt;code&gt;write&lt;/code&gt;: accès en lecture/écriture&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;L'option &lt;code&gt;realm&lt;/code&gt; permet de spécifier un nom pour le dépôt et l'option
&lt;code&gt;password-db&lt;/code&gt; de spécifier où seront stockées les logins et mots de passe
des utilisateurs.&lt;/p&gt;
&lt;p&gt;Le fichier &lt;code&gt;password&lt;/code&gt; ressemble à ceci:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[users]&lt;/span&gt;
&lt;span class="na"&gt;login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;mot_de_passe&lt;/span&gt;
&lt;span class="na"&gt;login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;mot_de_passe&lt;/span&gt;
&lt;span class="na"&gt;login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;mot_de_passe&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://wiki.sharlaan.net/howto:svnserve"&gt;howto:svnserve&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="SVN"></category><category term="remote"></category><category term="Debian"></category></entry><entry><title>Installation d'un serveur LDAP pour authentification</title><link href="https://blog.tblein.eu/server/2009/Installation-of-a-LDAP-server-for-authentication/index-fr.html" rel="alternate"></link><published>2009-06-23T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-06-23:server/2009/Installation-of-a-LDAP-server-for-authentication/index-fr.html</id><summary type="html">&lt;div class="section" id="installation-du-serveur-ldap"&gt;
&lt;h2&gt;Installation du serveur LDAP&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install slapd ldap-utils
&lt;span class="gp"&gt;#&lt;/span&gt; dpkg-reconfigure slapd
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Suivre les recommandations&lt;/p&gt;
&lt;p&gt;On crée ensuite la structure de l'annuaire pour accueillir les utilisateurs et
les groupes. Pour cela on crée le fichier &lt;code&gt;/tmp/base.ldif&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;dn: ou=People,dc=mondomaine,dc=tld
ou: People
objectClass: top
objectClass: organizationalUnit

dn: ou=Group,dc=mondomaine,dc=tld
ou: Group
objectClass: top
objectClass: organizationalUnit
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On l'importe ensuite dans l'annuaire:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ldapadd -D &lt;span class="s1"&gt;&amp;#39;cn=admin, dc=mondomaine, dc=tld&amp;#39;&lt;/span&gt; -c -x -W -f /tmp/base.ldif
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="recuperation-des-utilisateurs-et-groupes-actuels"&gt;
&lt;h2&gt;Récupération des utilisateurs et groupes actuels&lt;/h2&gt;
&lt;p&gt;Pour cela on va utiliser une série de scripts permettant contenus dans le paquet
&lt;code&gt;migrationtools&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install migrationtools
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Éditer le fichier &lt;code&gt;/etc/migrationtools/migrate_common.pl&lt;/code&gt; et suivre les
recommandations de &lt;a class="reference external" href="http://wiki.gcu.info/doku.php?id=linux:auth_ldap"&gt;http://wiki.gcu.info/doku.php?id=linux:auth_ldap&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Récupération des information d'utilisateur et de groupe du système dans un
fichier LDIF permettant un import facile dans l'annuaire LDAP:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /usr/share/migrationtools
&lt;span class="gp"&gt;#&lt;/span&gt; ./migrate_passwd.pl /etc/passwd &lt;span class="p"&gt;|&lt;/span&gt; grep -v &lt;span class="s1"&gt;&amp;#39;objectClass: account&amp;#39;&lt;/span&gt; &amp;gt; /tmp/passwd.ldif
&lt;span class="gp"&gt;#&lt;/span&gt; ./migrate_group.pl /etc/group /tmp/group.ldif
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les utilisateurs qui seront inclus dans l'annuaire sont enregistrés dans le
fichier &lt;code&gt;/tmp/passwd.ldif&lt;/code&gt; et les groupes dans &lt;code&gt;/tmp/group.ldif&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Ajouter pour chaque utilisateur&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;objectClass: account
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Avant les autres &lt;code&gt;objectClass&lt;/code&gt;, sinon erreur lors de l'import du type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;ldap_add: Object class violation (65)&lt;/span&gt;
&lt;span class="go"&gt;additional info: no structural object class provided&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On ajoute ensuite les utilisateurs et groupes dans l'annuaire:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ldapadd -D &lt;span class="s1"&gt;&amp;#39;cn=admin, dc=mondomaine, dc=tld&amp;#39;&lt;/span&gt; -c -x -W -f /tmp/passwd.ldif
&lt;span class="gp"&gt;#&lt;/span&gt; ldapadd -D &lt;span class="s1"&gt;&amp;#39;cn=admin, dc=mondomaine, dc=tld&amp;#39;&lt;/span&gt; -c -x -W -f /tmp/group.ldif
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="utilisateur-en-lecture-de-la-base-pour-authentification"&gt;
&lt;h2&gt;Utilisateur en lecture de la base pour authentification&lt;/h2&gt;
&lt;p&gt;Éditer &lt;code&gt;/etc/ldap/slapd.conf&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;rootdn          &amp;quot;cn=admin,dc=mondomaine,dc=tld&amp;quot;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service slapd restart
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Création des information de l'utilisateur &lt;code&gt;nss&lt;/code&gt; dans un nouveau fichier
&lt;code&gt;/tmp/nss.ldif&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;dn: cn=nss,dc=mondomaine,dc=tld
objectClass: organizationalRole
objectClass: simpleSecurityObject
cn: nss
description: LDAP NSS user for user-lookups
userPassword:
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Obtention du mot de passe:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;slappasswd -h {CRYPT}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ajout de l'utilisateur de lecture:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;ldapadd -D &amp;#39;cn=admin, dc=mondomaine, dc=tld&amp;#39; -c -x -W -f /tmp/nss.ldif&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
</summary><category term="LDAP"></category><category term="authentication"></category><category term="Debian"></category></entry><entry><title>Installation de phpLDAPadmin pour lighttpd</title><link href="https://blog.tblein.eu/server/2009/Installation-of-phpLDAPadmin-with-lighttpd/index-fr.html" rel="alternate"></link><published>2009-06-23T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-06-23:server/2009/Installation-of-phpLDAPadmin-with-lighttpd/index-fr.html</id><summary type="html">&lt;p&gt;L'installation du serveur lighttpd avec PHP5 est nécessaire (voir &lt;a class="reference external" href="https://blog.tblein.eu/server/2016/PHP-activation-for-lighttpd/index-fr.html"&gt;Activation de
PHP pour lighttpd&lt;/a&gt;)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install phpldapadmin
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les scripts de phpLDAPadmin sont situés dans le dossier
&lt;code&gt;/usr/share/phpldapadmin&lt;/code&gt;. Pour y avoir accès il suffit de créer le
fichier de configuration
&lt;code&gt;/etc/lighttpd/conf-available/50-phpldapadmin.conf&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;# Alias for phpLDAPadmin directory&lt;/span&gt;
&lt;span class="k"&gt;alias.url&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s2"&gt;&amp;quot;/phpldapadmin&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/usr/share/phpldapadmin&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Disallow access to libraries&lt;/span&gt;
&lt;span class="nb"&gt;$HTTP&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=~&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;^/phpldapadmin/lib&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;url.access-deny&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Enfin pour l'activer un simple lien dans le dossier
&lt;code&gt;/etc/lighttpd/conf-enable/&lt;/code&gt; et un redémarrage du serveur web&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; ln -s /etc/lighttpd/conf-available/50-phpldapadmin.conf /etc/lighttpd/conf-enabled/
&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/lighttpd restart
&lt;/pre&gt;&lt;/div&gt;
</summary><category term="LDAP"></category><category term="lighttpd"></category><category term="phpLDAPadmin"></category></entry><entry><title>Sauvegarde et restauration d'un serveur LDAP</title><link href="https://blog.tblein.eu/server/2009/LDAP-server-backup-restore/index-fr.html" rel="alternate"></link><published>2009-06-23T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-06-23:server/2009/LDAP-server-backup-restore/index-fr.html</id><summary type="html">&lt;div class="section" id="sauvegarde-des-donnees-d-un-serveur-ldap"&gt;
&lt;h2&gt;Sauvegarde des données d'un serveur LDAP&lt;/h2&gt;
&lt;p&gt;Pour cela il suffit de sauvegarder la base dans un fichier LDIF. Le dump de la
base LDAP s'effectue à l'aide de la commande &lt;code&gt;slapcat&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; slapcat &amp;gt; base.ldif
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="restauration-des-donnees-d-un-serveur-ldap"&gt;
&lt;h2&gt;Restauration des données d'un serveur LDAP&lt;/h2&gt;
&lt;p&gt;Pour charger le fichier dans le serveur il faut utiliser la commande
&lt;code&gt;slapadd&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; service slapd stop
&lt;span class="gp"&gt;#&lt;/span&gt; slapadd &amp;lt; base.ldif
&lt;span class="gp"&gt;#&lt;/span&gt; service slapd start
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Le serveur de destination doit posséder un schéma de base lui permettant de
prendre en charge les données du fichier sous peine d'un message d'erreur.&lt;/p&gt;
&lt;p&gt;De même si des entrées existent déjà dans la base de destination, l'importation
s'arrêtera.&lt;/p&gt;
&lt;/div&gt;
</summary><category term="LDAP"></category><category term="backup"></category><category term="restore"></category></entry><entry><title>Sécurisation des dossiers temporaires</title><link href="https://blog.tblein.eu/server/2009/securing-tmp-folders/index-fr.html" rel="alternate"></link><published>2009-06-23T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-06-23:server/2009/securing-tmp-folders/index-fr.html</id><summary type="html">&lt;p&gt;Le dossier &lt;code&gt;/tmp&lt;/code&gt; est l'un des rares dossier du système qui soit
accessible en écriture par tout le monde. Les utilisateur comme les services.
Cependant beaucoup de vers utilisent des failles des application web pour
déposer un fichier sur le serveur et arrive donc dans ce fameux dossier
temporaire d'où le fichier peut être exécuter.&lt;/p&gt;
&lt;p&gt;Afin de s'en prémunir il suffit de rendre le dossier temporaire non exécutable.&lt;/p&gt;
&lt;div class="section" id="monage-du-dossier-tmp-en-lecture-ecriture-seules"&gt;
&lt;h2&gt;Monage du dossier &lt;code&gt;/tmp&lt;/code&gt; en lecture/écriture seules&lt;/h2&gt;
&lt;p&gt;Pour inactivé l'exécution globalement dans un  répertoire, il faut que cela
concerne toute une partition. Il y a donc deux possibilité: soit le répertoire
&lt;code&gt;/tmp&lt;/code&gt; est déjà une partition à part soit il faut en crée une pour lui.
Plutôt que de reformater complètement le disque pour créer cette partition, il
est possible de transformer un fichier en partition &lt;code&gt;loopback&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Pour cela il faut d'abord créer ce fichier comme dans l'article &lt;a class="reference external" href="https://blog.tblein.eu/general/2009/creation-de-fichier-image-disque-et-montage/index-fr.html"&gt;Création de
fichier image disque et montage&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Pour monter le fichier automatiquement au démarrage il suffit d'ajouter la ligne suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;/fichier_temporaire&lt;/span&gt; &lt;span class="err"&gt;/tmp&lt;/span&gt; &lt;span class="err"&gt;ext3&lt;/span&gt; &lt;span class="err"&gt;loop,noexec,nosuid,nodev,rw&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Où &lt;code&gt;fichier_temporaire&lt;/code&gt; est le chemin complet vers le fichier contenant la
partition destiné au répertoire temporaire. Les options
&lt;code&gt;noexec,nosuid,nodev&lt;/code&gt; permettent de bloquer l'exécution sur cette
partition.&lt;/p&gt;
&lt;p&gt;Dans le cas ou le dossier temporaire serait déjà sur une partition séparée,
l'ajout des options &lt;code&gt;noexec,nosuid,nodev&lt;/code&gt; pour l'entrée du fichier
&lt;code&gt;/etc/fstab&lt;/code&gt; correspondante permettra de bloquer l'exécution sur cette
partition.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="dpkg-et-erreur-d-execution"&gt;
&lt;h2&gt;DPKG et erreur d'exécution&lt;/h2&gt;
&lt;p&gt;Lors de l'installation de paquets, les scripts de configurations sont placé dans
le répertoire &lt;code&gt;/tmp&lt;/code&gt; et exécutés. Cependant comme l'exécution est bloqué
il ne peuvent pas se configurer renvoyant une erreur semblable à la suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;Can&amp;#39;t exec &amp;quot;/tmp/quota.config.26141&amp;quot;: Permission non accordée at /usr/share/perl/5.8/IPC/Open3.pm line 168&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Lors de l'installation de paquets il faut donc rendre exécutable le répertoire
temporaire via la commande suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mount -o remount,exec /tmp
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Enfin, une fois les paquets installé la partition est de nouveau rendue non
exécutable via la commande:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mount -o remount,noexec /tmp
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Il est possible de demander à &lt;code&gt;dpkg&lt;/code&gt; de se débrouiller tout seul pour
faire ce changement de permission sur le répertoire &lt;code&gt;/tmp&lt;/code&gt; via un petit
script de . Pour cela il suffit de modifier le fichier
&lt;code&gt;/etc/apt/apt.conf.d/70debconf&lt;/code&gt; pour qu'il ressemble à ceci:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;//changement des permission d&amp;#39;exécution du répertoire /tmp&lt;/span&gt;
&lt;span class="n"&gt;DPkg&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Pre&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Install&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Pkgs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;mount -o remount,exec /tmp; /usr/sbin/dpkg-preconfigure --apt || true&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;};&lt;/span&gt;
&lt;span class="n"&gt;DPkg&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Invoke&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;mount -o remount,noexec /tmp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Une configuration analogue peut être effectuée avec le répertoire &lt;code&gt;/var&lt;/code&gt;.
Cependant vue la taille que ce répertoire peut atteindre lors de l'utilisation
d'un serveur web il est conseillé d'utiliser une vraie partition et non un
fichier loopback. Il faut également modifier le fichier
&lt;code&gt;/etc/apt/apt.conf.d/70debconf&lt;/code&gt;, dpkg utilisant le répertoire
&lt;code&gt;/var/cache/apt/&lt;/code&gt; pour dépaqueter les paquets:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;//changement des permission d&amp;#39;exécution du répertoire /tmp&lt;/span&gt;
&lt;span class="n"&gt;DPkg&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Pre&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Install&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Pkgs&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;mount -o remount,exec /tmp; mount -o remount,exec /var; /usr/sbin/dpkg-preconfigure --apt || true&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;};&lt;/span&gt;
&lt;span class="n"&gt;DPkg&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Invoke&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;mount -o remount,noexec /tmp; mount -o remount,noexec /var;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://howto.landure.fr/gnu-linux/debian-4-0-etch/securiser-votre-dossier-temporaire"&gt;Sécuriser votre dossier temporaire&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.linuxaide.org/index.php/APT_avec_/tmp_en_noexec"&gt;APT avec /tmp en noexec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</summary><category term="security"></category><category term="temporary folders"></category><category term="Debian"></category><category term="dpkg"></category></entry><entry><title>rkhunter</title><link href="https://blog.tblein.eu/server/2009/rkhunter/" rel="alternate"></link><published>2009-06-22T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-06-22:server/2009/rkhunter/</id><summary type="html">&lt;p&gt;Pour chercher les rootkits présents sur le système et autre vers.&lt;/p&gt;
&lt;div class="section" id="installation"&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; aptitude install rkunter
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;La configuration à lieu dans le fichier &lt;code&gt;/etc/rkhunter.conf&lt;/code&gt;. Par défaut
certains tests sont inactivés comme par exemple &lt;code&gt;hidden_procs&lt;/code&gt; qui
a besoin du paquet &lt;code&gt;unhide&lt;/code&gt;. Pour l'activer il suffit de l'enlever de la
liste &lt;code&gt;DISABLE_TESTS&lt;/code&gt; (ligne 199).&lt;/p&gt;
&lt;p&gt;De même la vérification des paquet via le système de paquet est désactivé par
défaut sur Debian puisqu'il met beaucoup de temps. Pour l'activer il faut
activer l'option &lt;code&gt;PKGMGR&lt;/code&gt; dans &lt;code&gt;/etc/rkhunter.conf&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;257 &lt;/span&gt;&lt;span class="na"&gt;PKGMGR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;DPKG&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="proc-modules"&gt;
&lt;h2&gt;/proc/modules&lt;/h2&gt;
&lt;p&gt;Sur le serveur RPS d'OVH il n'y a pas le fichier &lt;code&gt;/proc/modules&lt;/code&gt; ceci
entraine un avertissement lors des test. Pour empêcher que cela apparaisse en
permanence il suffit de désactivé ce test a l'aide de la variable
&lt;code&gt;DISABLE_TESTS&lt;/code&gt; auquel il faut ajouter la valeur &lt;code&gt;os_specific&lt;/code&gt; dans
&lt;code&gt;/etc/rkhunter&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;199 &lt;/span&gt;&lt;span class="na"&gt;DISABLE_TEST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;os_specific&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a class="reference external" href="http://osdir.com/ml/security.rkhunter.user/2007-07/msg00029.html"&gt;Message de la liste donnant la solution&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="probleme-lors-de-la-mise-a-jour-de-paquet"&gt;
&lt;h2&gt;Problème lors de la mise à jour de paquet&lt;/h2&gt;
&lt;p&gt;Lors de la mise à jour de paquets, certains fichiers peuvent être modifié et ne
plus correspondre à ce que rkhunter avait détecté précédemment. Cela entraine
donc des avertissements du style:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;Warning: The file properties have changed:&lt;/span&gt;
&lt;span class="go"&gt;         File: /sbin/syslogd&lt;/span&gt;
&lt;span class="go"&gt;         Current inode: 563364    Stored inode: 563394&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour mettre à jour la base de rkhunter concernant le suivi des modifications de
fichier, il suffit de lancer la commande suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;rkhunter --propupd&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cela peut être automatisé à chaque installation de paquet via un script lancé
par le système de paquet. Pour cela il suffit de créer le fichier
&lt;code&gt;/etc/apt/apt.conf.d/90rkhunter&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;// Update rkhunter file signatures databases after running dpkg.&lt;/span&gt;
&lt;span class="n"&gt;DPkg&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;Invoke&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s"&gt;&amp;quot;if [ -x /usr/bin/rkhunter ]; then if [ $(/usr/bin/rkhunter --help | /bin/grep &amp;quot;&lt;/span&gt;&lt;span class="n"&gt;propupd&lt;/span&gt;&lt;span class="s"&gt;&amp;quot; | /usr/bin/wc -l) -gt 0 ]; then /usr/bin/rkhunter --propupd; fi; fi&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
</summary><category term="security"></category><category term="rootkit"></category></entry><entry><title>Démarrage parallèle avec insserv</title><link href="https://blog.tblein.eu/server/2009/parallel-boot-start-with-insserv/index-fr.html" rel="alternate"></link><published>2009-05-07T00:00:00+02:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-05-07:server/2009/parallel-boot-start-with-insserv/index-fr.html</id><summary type="html">&lt;p&gt;Par défaut les services des systèmes Linux démarrent les uns après les autres.
Un moyen de gagner du temps lors du démarrage est de lancer les différent
services en parallèle ce qui évite de devoir attendre qu'un service ait fini de
démarrer pour en lancer d'autre.&lt;/p&gt;
&lt;p&gt;Pour cela il faut modifier l'option &lt;code&gt;CONCURRENCY&lt;/code&gt; dans le fichier
&lt;code&gt;/etc/init.d/rc&lt;/code&gt;. Par défaut elle est désactivée:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="lineno"&gt;39 &lt;/span&gt; &lt;span class="k"&gt;[...]&lt;/span&gt;
&lt;span class="lineno"&gt;40 &lt;/span&gt; &lt;span class="na"&gt;CONCURRENCY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;none&lt;/span&gt;
&lt;span class="lineno"&gt;41 &lt;/span&gt;&lt;span class="s"&gt; [...]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cette option peut prendre trois valeurs différentes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;code&gt;none&lt;/code&gt;: désactivation de l'option de démarrage concurrentiel&lt;/li&gt;
&lt;li&gt;&lt;code&gt;startpar&lt;/code&gt;: les services sont lancés en parallèle mais leur sortie reste
en série.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;shell&lt;/code&gt;: les services sont lancés en parallèle dans des shell différents
ainsi les sorties sont aussi parallélisées.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Plus la parallélisation augmente plus le temps de démarrage est raccourci.&lt;/p&gt;
&lt;p&gt;Cependant certains services doivent être lancés après d'autre. Pour cela il faut
réordonnancer les services pour être sur de ne pas démarrer un service tant que
les pré-requis ne sont pas remplis. Par exemple le service de mise à jour de
leur sur les serveur distant doit être lancé qu'une fois la connexion réseau
établie.&lt;/p&gt;
&lt;p&gt;Le paquet &lt;code&gt;insserv&lt;/code&gt; permet de calculer les dépendances des différents
scripts de démarrage, et ainsi de créer la hiérarchie nécessaire. Une fois
installé il faut lancé la commande suivante en root pour optimiser les scripts
init:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; update-bootsystem-insserv
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Lors d'une mise à jour du système des messages d'avertissement similaire au
suivant peuvent apparaitre:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;insserv: warning: current start runlevel(s) (0 6) of script `umountroot&amp;#39; overwrites defaults (empty).&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cela veut simplement dire que l'ordre de lancement d'un ou plusieurs scripts
init ont été modifiés lors de l'installation d'un ou plusieurs paquets. Il
suffit de relancer la commande &lt;code&gt;update-bootsystem-insserv&lt;/code&gt; pour refaire le
calcul de hiérarchie t faire disparaitre ces messages d'avertissement.&lt;/p&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://macsim.labolinux.net/index.php/post/2009/04/27/Accélérer-le-boot-d-ubuntu-et-debian"&gt;Accélérer le boot de debian et ubuntu par Macsim&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="boot"></category><category term="insserv"></category><category term="Debian"></category><category term="parallel"></category></entry><entry><title>Partage de fichier avec Network File System (NFS)</title><link href="https://blog.tblein.eu/server/2009/File-sharing-with-NFS/" rel="alternate"></link><published>2009-03-02T00:00:00+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-03-02:server/2009/File-sharing-with-NFS/</id><summary type="html">&lt;div class="section" id="installation-du-serveur-nfsv4"&gt;
&lt;h2&gt;Installation du serveur NFSv4&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; apt-get install nfs-kernel-server nfs-common portmap
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les configurations s'effectue dans le fichier &lt;code&gt;/etc/exports&lt;/code&gt;. La version
4 du protocole NFS permet de monter les répertoires partagés à partir d'une
racine virtuelle. Il faut ajouter la ligne suivante au fichier
&lt;code&gt;/etc/exports&lt;/code&gt; pour que cette racine virtuelle soit &lt;code&gt;/exports&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="na"&gt;/export       192.168.1.0/24(rw,fsid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;0,insecure,no_subtree_check)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration"&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;Les sous répertoires du répertoire &lt;code&gt;/exports&lt;/code&gt; seront donc partagés. Ainsi
pour partager un nouveau répertoires il suffit de l'ajouter au répertoire
&lt;code&gt;/exports&lt;/code&gt; à l'aide de la commande suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mount --bind /home /exports/home
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Afin que ce partage soit effectif à chaque démarrage du système il faut ajouter
la ligne suivante dans le fichier &lt;code&gt;/etc/fstab&lt;/code&gt; du serveur:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;/home&lt;/span&gt;           &lt;span class="err"&gt;/exports/home&lt;/span&gt;   &lt;span class="err"&gt;none&lt;/span&gt;    &lt;span class="err"&gt;rw,bind&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;   &lt;span class="err"&gt;0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Les règles de partage de ce répertoire se font de la même façon qu'avec la
version 3 de NFS via l'édition du fichier &lt;code&gt;/etc/exports&lt;/code&gt;. Chaque ligne
commence par le chemin absolue du répertoire à partager suivie d'une liste des
clients avec le détail de configuration.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;/exports/home&lt;/span&gt;    &lt;span class="err"&gt;192.168.1.0/24(rw,nohide,sync,insecure,root_squash,no_subtree_check)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour prendre en compte les différents points de montage il faut redémarrer le
serveur NFS avec la commande suivante:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; /etc/init.d/nfs-kernel-server restart
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="montage"&gt;
&lt;h2&gt;Montage&lt;/h2&gt;
&lt;p&gt;Pour monter le système de fichier NFS sur le système de fichier du client il
suffit d'utiliser la commande suivante qui va nous permettre de monter la
totalité des répertoires exportés:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mount -t nfs4 192.168.1.15:/ /media/nfs
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pour rendre ce montage définitif la ligne suivante doit être ajouter au fichier
&lt;code&gt;/ect/fstab&lt;/code&gt; de la machine cliente:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;server:/home&lt;/span&gt; &lt;span class="err"&gt;/home&lt;/span&gt; &lt;span class="err"&gt;nfs4&lt;/span&gt; &lt;span class="err"&gt;rw&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.crazysquirrel.com/computing/debian/servers/setting-up-nfs4.jspx"&gt;Setting up NFSv4&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="share"></category><category term="NFS"></category><category term="Debian"></category><category term="files"></category></entry><entry><title>Jygraphe: Partage de gros fichiers personnel</title><link href="https://blog.tblein.eu/server/2009/Personnal-big-file-share-with-Jyraphe/index-fr.html" rel="alternate"></link><published>2009-02-16T00:00:00+01:00</published><author><name>Thomas Blein</name></author><id>tag:blog.tblein.eu,2009-02-16:server/2009/Personnal-big-file-share-with-Jyraphe/index-fr.html</id><summary type="html">&lt;div class="section" id="installation"&gt;
&lt;h2&gt;Installation&lt;/h2&gt;
&lt;p&gt;Récupérer l'archive de Jyraphe et la décompresser&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt; wget http://download.gna.org/jyraphe/jyraphe-0.3.tar.gz
&lt;span class="gp"&gt;$&lt;/span&gt; tar xvzf jyraphe-0.3.tar.gz
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;En tant que super-utilisateur déplacer dans un répertoire accessible par le
serveur et changement de droit pour être éditable par le serveur.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; mv jyraphe-0.3/pub /var/www/jyraphe
&lt;span class="gp"&gt;#&lt;/span&gt; chown www-data:www-data /var/www/jyraphe/
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration"&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;Lancer le script d'installation en allant à l'adresse
&lt;a class="reference external" href="http://votreserveur/jyraphe"&gt;http://votreserveur/jyraphe&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Créez le dossier qui contiendra les fichiers à télécharger&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;mkdir /var/www/jyraphe/var-********&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Empêchez l'écriture du fichier de configuration et supprimez le script
d'installation&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt; chmod &lt;span class="m"&gt;500&lt;/span&gt; /var/www/jyraphe/lib/config.local.php
&lt;span class="gp"&gt;#&lt;/span&gt; rm /var/www/jyraphe/install.php
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="configuration-de-la-taille-maximal-des-fichiers"&gt;
&lt;h2&gt;Configuration de la taille maximal des fichiers&lt;/h2&gt;
&lt;p&gt;Réglez la taille maximal d'upload des fichiers en mofifiant le fichier
&lt;code&gt;php.ini&lt;/code&gt;. Pour la version CGI, &lt;code&gt;/etc/php5/cgi/php.ini&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;; Maximum size of POST data that PHP will accept.&lt;/span&gt;
&lt;span class="na"&gt;post_max_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;100M&lt;/span&gt;

&lt;span class="k"&gt;[...]&lt;/span&gt;

&lt;span class="c1"&gt;; Maximum allowed size for uploaded files.&lt;/span&gt;
&lt;span class="na"&gt;upload_max_filesize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;100M&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Redémarrez le serveur web pour prendre en compte le changement par exemple pour
lighttpd:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="go"&gt;/etc/init.d/lighttpd restart&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sources"&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://home.gna.org/jyraphe/"&gt;site web de Jygraphe&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</summary><category term="PHP"></category><category term="share"></category><category term="big files"></category></entry></feed>