index.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <link rel="shortcut icon" href="../img/favicon.ico">
  9. <title>Installation des certificats letsencrypt - Les Tutoriels du Yojik</title>
  10. <link rel="stylesheet" href="../css/theme.css" />
  11. <link rel="stylesheet" href="../css/theme_extra.css" />
  12. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
  13. <script>
  14. // Current page data
  15. var mkdocs_page_name = "Installation des certificats letsencrypt";
  16. var mkdocs_page_input_path = "Installation-Certificats-Letsencrypt.md";
  17. var mkdocs_page_url = null;
  18. </script>
  19. <script src="../js/jquery-2.1.1.min.js" defer></script>
  20. <script src="../js/modernizr-2.8.3.min.js" defer></script>
  21. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  22. <script>hljs.initHighlightingOnLoad();</script>
  23. </head>
  24. <body class="wy-body-for-nav" role="document">
  25. <div class="wy-grid-for-nav">
  26. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  27. <div class="wy-side-scroll">
  28. <div class="wy-side-nav-search">
  29. <a href=".." class="icon icon-home"> Les Tutoriels du Yojik</a>
  30. <div role="search">
  31. <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <p class="caption"><span class="caption-text">Installation d'un serveur sécurisé, version Debian/Stretch (obsolète)</span></p>
  38. <ul>
  39. <li class="toctree-l1"><a class="reference internal" href="..">Présentation</a>
  40. </li>
  41. </ul>
  42. <p class="caption"><span class="caption-text">Installation</span></p>
  43. <ul class="current">
  44. <li class="toctree-l1"><a class="reference internal" href="../Installation-de-base/">Installation du système de base</a>
  45. </li>
  46. <li class="toctree-l1"><a class="reference internal" href="../ovh/">Démarrage sur serveur OVH</a>
  47. </li>
  48. <li class="toctree-l1"><a class="reference internal" href="../Premi%C3%A8re-Etape-S%C3%A9curisation/">Première étapes de sécurisation du serveur</a>
  49. </li>
  50. <li class="toctree-l1"><a class="reference internal" href="../Configuration-R%C3%A9seau/">Configuration du réseau</a>
  51. </li>
  52. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-Temps/">Installation d'un serveur de temps</a>
  53. </li>
  54. <li class="toctree-l1"><a class="reference internal" href="../Installation-Parre-Feu/">Installation d'un pare-feu</a>
  55. </li>
  56. <li class="toctree-l1"><a class="reference internal" href="../Installation-Fail2ban/">Contrer les attaques de brute-force avec fail2ban</a>
  57. </li>
  58. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-Courrier-Basique/">Installation d'un serveur de courrier basique</a>
  59. </li>
  60. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-DNS/">Installation du serveur DNS</a>
  61. </li>
  62. <li class="toctree-l1"><a class="reference internal" href="../Installation-Serveur-Web/">Installation d'un serveur web</a>
  63. </li>
  64. <li class="toctree-l1"><a class="reference internal" href="../Installation-Dovecot-Authentification/">Installation de dovecot et de l'authentification</a>
  65. </li>
  66. <li class="toctree-l1 current"><a class="reference internal current" href="./">Installation des certificats letsencrypt</a>
  67. <ul class="current">
  68. <li class="toctree-l2"><a class="reference internal" href="#installation-des-programmes">Installation des programmes</a>
  69. </li>
  70. <li class="toctree-l2"><a class="reference internal" href="#creation-des-certificats-pour-nos-domaines">Création des certificats pour nos domaines</a>
  71. </li>
  72. <li class="toctree-l2"><a class="reference internal" href="#lancement-du-programme-certbot">lancement du programme certbot</a>
  73. </li>
  74. </ul>
  75. </li>
  76. <li class="toctree-l1"><a class="reference internal" href="../Courrier-SPF-DKIM-OPENDMARC/">Ajout des enregistrements **spf**, **DKIM**, **DMARC** au fichier de zone DNS</a>
  77. </li>
  78. <li class="toctree-l1"><a class="reference internal" href="../Courrier-Comptes-Virtuels/">Ajout des comptes émail virtuels</a>
  79. </li>
  80. <li class="toctree-l1"><a class="reference internal" href="../Surveillance-Serveur/">Installation de programmes de surveillance du serveur</a>
  81. </li>
  82. <li class="toctree-l1"><a class="reference internal" href="../Installation-Webmail/">Installation d'un webmail (rainloop)</a>
  83. </li>
  84. <li class="toctree-l1"><a class="reference internal" href="../S%C3%A9curisation-Serveur-Web/">Sécurisation d'un serveur WEB</a>
  85. </li>
  86. </ul>
  87. </div>
  88. </div>
  89. </nav>
  90. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  91. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  92. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  93. <a href="..">Les Tutoriels du Yojik</a>
  94. </nav>
  95. <div class="wy-nav-content">
  96. <div class="rst-content">
  97. <div role="navigation" aria-label="breadcrumbs navigation">
  98. <ul class="wy-breadcrumbs">
  99. <li><a href="..">Docs</a> &raquo;</li>
  100. <li>Installation &raquo;</li>
  101. <li>Installation des certificats letsencrypt</li>
  102. <li class="wy-breadcrumbs-aside">
  103. </li>
  104. </ul>
  105. <hr/>
  106. </div>
  107. <div role="main">
  108. <div class="section">
  109. <h1 id="installation-des-certificats-letsencrypt">Installation des certificats letsencrypt</h1>
  110. <h2 id="installation-des-programmes">Installation des programmes</h2>
  111. <p>Il existe plusieurs clients <strong>letsencrypt</strong> pour la gestion des certificats. Nous utiliserons <strong>certbot</strong>, le client officiel de <strong>letsencrypt</strong>.</p>
  112. <pre><code>root@atom:/home/ericadmin/bin# apt install certbot python-certbot-apache
  113. Lecture des listes de paquets... Fait
  114. Construction de l'arbre des dépendances
  115. Lecture des informations d'état... Fait
  116. The following additional packages will be installed:
  117. augeas-lenses libaugeas0 python-acme python-augeas python-certbot python-cffi-backend python-chardet python-configargparse python-configobj python-cryptography
  118. python-dnspython python-enum34 python-funcsigs python-idna python-ipaddress python-mock python-openssl python-parsedatetime python-pbr python-pkg-resources python-psutil
  119. python-pyasn1 python-pyicu python-requests python-rfc3339 python-setuptools python-six python-tz python-urllib3 python-zope.component python-zope.event
  120. python-zope.hookable python-zope.interface
  121. etc...
  122. </code></pre>
  123. <h2 id="creation-des-certificats-pour-nos-domaines">Création des certificats pour nos domaines</h2>
  124. <p>Bien, les programmes sont installés. Nous allons créer des certificats pour les domaines suivantes, après avoir créé les hôtes virtuels apache.</p>
  125. <ul>
  126. <li>yojik.net</li>
  127. <li>www.yojik.net</li>
  128. <li>atom.yojik.net</li>
  129. </ul>
  130. <p>Les 2 premiers concernent le site web, le dernier, le serveur de mail. Nous allons d'abord rajouter les noms manquants dans le fichier de zone DNS; pour l'instant, nous n'avons déclaré qu'un seul nom: atom.yojik.net. Rajoutons les suivants avec des enregistrements CNAME. Ne pas oublier d'incrémenter le compteur situé dans le fichier de zone DNS après chaque modification.</p>
  131. <p>Lors de l'installation de notre webmail, nous rajouterons le domaine correspondant.</p>
  132. <p>Nous ajoutons ici la référence du serveur web, avec un enregistrement CNAME: www.yojik.eu</p>
  133. <pre><code>www IN CNAME atom.yojik.net.
  134. </code></pre>
  135. <p>Relecture des fichiers de configuration par bind:</p>
  136. <pre><code>root@atom:/home/ericadmin# service bind9 reload
  137. </code></pre>
  138. <h2 id="lancement-du-programme-certbot">lancement du programme certbot</h2>
  139. <pre><code>root@atom:/home/ericadmin# certbot --apache
  140. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  141. Which names would you like to activate HTTPS for?
  142. -
  143. 1: yojik.net
  144. 2: www.yojik.net
  145. -
  146. Select the appropriate numbers separated by commas and/or spaces, or leave input
  147. blank to select all options shown (Enter 'c' to cancel):1 2
  148. Obtaining a new certificate
  149. Performing the following challenges:
  150. Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA.
  151. Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA.
  152. </code></pre>
  153. <p>Bon, il y a un problème ... après recherche sur le web, il se trouve que le programme certbot de Debian/stretch n'est pas à jour (modification due à un problème de sécurité.)</p>
  154. <ul>
  155. <li>
  156. <p>Voici le lien:</p>
  157. <p><a href="https://community.letsencrypt.org/t/solution-client-with-the-currently-selected-authenticator-does-not-support-any-combination-of-challenges-that-will-satisfy-the-ca/49983">certbot sur Debian/Stretch problem and solution</a></p>
  158. </li>
  159. <li>
  160. <p>Ajout des backports dans la liste des dépots:</p>
  161. <p>Il nous faut ajouter dans /etc/sources.list le dépot <strong>backports</strong> pour obtenir le fichier qui suit:</p>
  162. <p>Lien: <a href="https://backports.debian.org/Instructions/">Installation des backports</a></p>
  163. <p>Voici le contenu du fichier <em>etc/apt/sources.list</em></p>
  164. <pre><code>root@atom:/home/ericadmin# cat /etc/apt/sources.list
  165. #
  166. # deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main
  167. #deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main
  168. deb http://deb.debian.org/debian/ stretch main contrib
  169. deb-src http://deb.debian.org/debian/ stretch main contrib
  170. deb http://security.debian.org/debian-security stretch/updates main contrib
  171. deb-src http://security.debian.org/debian-security stretch/updates main contrib
  172. # stretch-updates, previously known as 'volatile'
  173. deb http://deb.debian.org/debian/ stretch-updates main contrib
  174. deb-src http://deb.debian.org/debian/ stretch-updates main contrib
  175. deb http://ftp.debian.org/debian stretch-backports main contrib
  176. </code></pre>
  177. <p>Notez la dernière ligne rajoutée au fichier. Ensuite,entrez les commandes suivantes:</p>
  178. <pre><code>apt update
  179. apt-get install python-certbot-apache -t stretch-backports
  180. </code></pre>
  181. <p>Un grand nombre de paquets vont être installés ...</p>
  182. </li>
  183. </ul>
  184. <p>On relance le programme certbot:</p>
  185. <pre><code>certbot --apache
  186. </code></pre>
  187. <p>Cette fois-ci, ça fonctionne.</p>
  188. <pre><code>root@atom:/home/ericadmin# certbot --apache
  189. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  190. Plugins selected: Authenticator apache, Installer apache
  191. Which names would you like to activate HTTPS for?
  192. -
  193. 1: yojik.net
  194. 2: www.yojik.net
  195. -
  196. Select the appropriate numbers separated by commas and/or spaces, or leave input
  197. blank to select all options shown (Enter 'c' to cancel): 1
  198. Obtaining a new certificate
  199. Performing the following challenges:
  200. http-01 challenge for yojik.net
  201. Waiting for verification...
  202. Cleaning up challenges
  203. Created an SSL vhost at /etc/apache2/sites-available/yojiknet-le-ssl.conf
  204. Deploying Certificate to VirtualHost /etc/apache2/sites-available/yojiknet-le-ssl.conf
  205. Enabling available site: /etc/apache2/sites-available/yojiknet-le-ssl.conf
  206. Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
  207. -
  208. 1: No redirect - Make no further changes to the webserver configuration.
  209. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
  210. new sites, or if you're confident your site works on HTTPS. You can undo this
  211. change by editing your web server's configuration.
  212. -
  213. Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
  214. Redirecting vhost in /etc/apache2/sites-enabled/yojiknet.conf to ssl vhost in /etc/apache2/sites-available/yojiknet-le-ssl.conf
  215. -
  216. Congratulations! You have successfully enabled https://yojik.net
  217. You should test your configuration at:
  218. https://www.ssllabs.com/ssltest/analyze.html?d=yojik.net
  219. -
  220. IMPORTANT NOTES:
  221. - Congratulations! Your certificate and chain have been saved at:
  222. /etc/letsencrypt/live/yojik.net/fullchain.pem
  223. Your key file has been saved at:
  224. /etc/letsencrypt/live/yojik.net/privkey.pem
  225. Your cert will expire on 2018-08-19. To obtain a new or tweaked
  226. version of this certificate in the future, simply run certbot again
  227. with the "certonly" option. To non-interactively renew *all* of
  228. your certificates, run "certbot renew"
  229. - If you like Certbot, please consider supporting our work by:
  230. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  231. Donating to EFF: https://eff.org/donate-le
  232. root@atom:/home/ericadmin#
  233. </code></pre>
  234. <p>On retape les mêmes commandes pour générer les certificats pour le domaine <strong>www.yojik.net</strong>.</p>
  235. <p>Testez votre configuration comme indiqué ci-dessus. Vous devez obtenir une note <strong>A</strong>.</p>
  236. <p>Il nous faut maintenant créer un certificat pour notre serveur mail:</p>
  237. <pre><code>root@atom:/home/ericadmin# certbot certonly -d atom.yojik.net
  238. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  239. How would you like to authenticate with the ACME CA?
  240. -
  241. 1: Apache Web Server plugin - Beta (apache)
  242. 2: Spin up a temporary webserver (standalone)
  243. 3: Place files in webroot directory (webroot)
  244. -
  245. Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 1
  246. Plugins selected: Authenticator apache, Installer None
  247. Obtaining a new certificate
  248. Performing the following challenges:
  249. http-01 challenge for atom.yojik.net
  250. Waiting for verification...
  251. Cleaning up challenges
  252. IMPORTANT NOTES:
  253. - Congratulations! Your certificate and chain have been saved at:
  254. /etc/letsencrypt/live/atom.yojik.net/fullchain.pem
  255. Your key file has been saved at:
  256. /etc/letsencrypt/live/atom.yojik.net/privkey.pem
  257. Your cert will expire on 2018-08-19. To obtain a new or tweaked
  258. version of this certificate in the future, simply run certbot
  259. again. To non-interactively renew *all* of your certificates, run
  260. "certbot renew"
  261. - If you like Certbot, please consider supporting our work by:
  262. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  263. Donating to EFF: https://eff.org/donate-le
  264. root@atom:/home/ericadmin#
  265. </code></pre>
  266. <p>Voilà, nos certificats sont créés. Lors de la configuration, notez que j'ai demandé une redirection automatique vers la version en <strong>https</strong>.</p>
  267. </div>
  268. </div>
  269. <footer>
  270. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  271. <a href="../Courrier-SPF-DKIM-OPENDMARC/" class="btn btn-neutral float-right" title="Ajout des enregistrements **spf**, **DKIM**, **DMARC** au fichier de zone DNS">Next <span class="icon icon-circle-arrow-right"></span></a>
  272. <a href="../Installation-Dovecot-Authentification/" class="btn btn-neutral" title="Installation de dovecot et de l'authentification"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  273. </div>
  274. <hr/>
  275. <div role="contentinfo">
  276. <!-- Copyright etc -->
  277. </div>
  278. Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  279. </footer>
  280. </div>
  281. </div>
  282. </section>
  283. </div>
  284. <div class="rst-versions" role="note" aria-label="versions">
  285. <span class="rst-current-version" data-toggle="rst-current-version">
  286. <span><a href="../Installation-Dovecot-Authentification/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  287. <span style="margin-left: 15px"><a href="../Courrier-SPF-DKIM-OPENDMARC/" style="color: #fcfcfc">Next &raquo;</a></span>
  288. </span>
  289. </div>
  290. <script>var base_url = '..';</script>
  291. <script src="../js/theme.js" defer></script>
  292. <script src="../search/main.js" defer></script>
  293. <script defer>
  294. window.onload = function () {
  295. SphinxRtdTheme.Navigation.enable(true);
  296. };
  297. </script>
  298. </body>
  299. </html>