index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 = "Tutoriels/tutostretch/Installation-Cerificats-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">Home</span></p>
  38. <ul>
  39. <li class="toctree-l1"><a class="reference internal" href="../../..">Page d'accueil</a>
  40. </li>
  41. </ul>
  42. <p class="caption"><span class="caption-text">Tutoriels</span></p>
  43. <ul>
  44. <li class="toctree-l1"><a class="reference internal" href="../../tutos/">Introduction</a>
  45. </li>
  46. <li class="toctree-l1"><a class="reference internal" href="#">Installation d'un serveur sécurisé, version Debian/Stretch (obsolète)</a>
  47. <ul>
  48. <li class="toctree-l2"><a class="reference internal" href="../tutostretch/">Présentation</a>
  49. </li>
  50. <li class="toctree-l2"><a class="reference internal" href="#">Installation</a>
  51. <ul>
  52. <li class="toctree-l3"><a class="reference internal" href="../Installation-de-base/">Installation du système de base</a>
  53. </li>
  54. <li class="toctree-l3"><a class="reference internal" href="../ovh/">Démarrage sur serveur OVH</a>
  55. </li>
  56. <li class="toctree-l3"><a class="reference internal" href="../Premi%C3%A8re-Etape-S%C3%A9curisation/">Première étapes de sécurisation du serveur</a>
  57. </li>
  58. <li class="toctree-l3"><a class="reference internal" href="../Configuration-R%C3%A9seau/">Configuration du réseau</a>
  59. </li>
  60. <li class="toctree-l3"><a class="reference internal" href="../Installation-Serveur-Temps/">Installation d'un serveur de temps</a>
  61. </li>
  62. <li class="toctree-l3"><a class="reference internal" href="../Installation-Parre-Feu/">Installation d'un pare-feu</a>
  63. </li>
  64. <li class="toctree-l3"><a class="reference internal" href="../Installation-Fail2ban/">Contrer les attaques de brute-force avec fail2ban</a>
  65. </li>
  66. <li class="toctree-l3"><a class="reference internal" href="../Installation-Serveur-Courrier-Basique/">Installation d'un serveur de courrier basique</a>
  67. </li>
  68. <li class="toctree-l3"><a class="reference internal" href="../Installation-Serveur-DNS/">Installation du serveur DNS</a>
  69. </li>
  70. <li class="toctree-l3"><a class="reference internal" href="../Installation-Serveur-Web/">Installation d'un serveur web</a>
  71. </li>
  72. <li class="toctree-l3"><a class="reference internal" href="../Installation-Dovecot-Authentification/">Installation de dovecot et de l'authentification</a>
  73. </li>
  74. <li class="toctree-l3"><a class="" href="../Installation-Certificats-Letsencrypt.md)">Installation des certificats letsencrypt</a>
  75. </li>
  76. <li class="toctree-l3"><a class="" href="../courrier-SPF-DKIM-OPENDMARC.md">Ajout des enregistrements **spf**, **DKIM**, **DMARC** au fichier de zone DNS</a>
  77. </li>
  78. <li class="toctree-l3"><a class="reference internal" href="../Courrier-Comptes-Virtuels/">Ajout des comptes émail virtuels</a>
  79. </li>
  80. <li class="toctree-l3"><a class="reference internal" href="../Surveillance-Serveur/">Installation de programmes de surveillance du serveur</a>
  81. </li>
  82. <li class="toctree-l3"><a class="reference internal" href="../Installation-Webmail/">Installation d'un webmail (rainloop)</a>
  83. </li>
  84. <li class="toctree-l3"><a class="" href="../Sécurisation-Serveur-Web">Sécurisation d'un serveur WEB</a>
  85. </li>
  86. </ul>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="toctree-l1"><a class="reference internal" href="#">Installation d'un serveur sécurisé, version Debian/Buster (en cours d'écriture)</a>
  91. <ul>
  92. <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/1-tutobuster/">Présentation</a>
  93. </li>
  94. <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/2-Installation-de-base/">Installation de base</a>
  95. </li>
  96. <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/3-ovh/">Démarrage sur serveur OVH</a>
  97. </li>
  98. <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/4-Plan/">Plan d'ensemble</a>
  99. </li>
  100. <li class="toctree-l2"><a class="reference internal" href="../../tutobuster/5-Premi%C3%A8re-Etape-S%C3%A9curisation/">Premières étapes de sécurisation du serveur</a>
  101. </li>
  102. </ul>
  103. </li>
  104. <li class="toctree-l1"><a class="reference internal" href="#">Installation d'un serveur sécurisé, version Debian/Buster sur RaspberryPI</a>
  105. <ul>
  106. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/tutoraspi/">Présentation</a>
  107. </li>
  108. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Installation-de-base/">Installation de base</a>
  109. </li>
  110. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Premier-d%C3%A9marrage/">Premier démarrage</a>
  111. </li>
  112. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Etat-des-lieux/">État des lieux</a>
  113. </li>
  114. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/S%C3%A9curisation-SSH/">Sécurisation SSH</a>
  115. </li>
  116. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/R%C3%A9seau/">Réseau (des IPs fixes)</a>
  117. </li>
  118. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Knot/">Installation de Knot-resolver</a>
  119. </li>
  120. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Firewall/">Installation d'un pare-feux</a>
  121. </li>
  122. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Fail2ban/">Contrer les attaques de force brute</a>
  123. </li>
  124. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Logwatch/">Surveillance du serveur</a>
  125. </li>
  126. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Installation-courrier-basique/">Installation d'un serveur de courriers basique</a>
  127. </li>
  128. <li class="toctree-l2"><a class="reference internal" href="../../tutoraspi/Annexe/">Annexe</a>
  129. </li>
  130. </ul>
  131. </li>
  132. </ul>
  133. </div>
  134. </div>
  135. </nav>
  136. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  137. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  138. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  139. <a href="../../..">Les Tutoriels du Yojik</a>
  140. </nav>
  141. <div class="wy-nav-content">
  142. <div class="rst-content">
  143. <div role="navigation" aria-label="breadcrumbs navigation">
  144. <ul class="wy-breadcrumbs">
  145. <li><a href="../../..">Docs</a> &raquo;</li>
  146. <li>Installation des certificats letsencrypt</li>
  147. <li class="wy-breadcrumbs-aside">
  148. </li>
  149. </ul>
  150. <hr/>
  151. </div>
  152. <div role="main">
  153. <div class="section">
  154. <h1 id="installation-des-certificats-letsencrypt">Installation des certificats letsencrypt</h1>
  155. <h2 id="installation-des-programmes">Installation des programmes</h2>
  156. <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>
  157. <pre><code>root@atom:/home/ericadmin/bin# apt install certbot python-certbot-apache
  158. Lecture des listes de paquets... Fait
  159. Construction de l'arbre des dépendances
  160. Lecture des informations d'état... Fait
  161. The following additional packages will be installed:
  162. augeas-lenses libaugeas0 python-acme python-augeas python-certbot python-cffi-backend python-chardet python-configargparse python-configobj python-cryptography
  163. python-dnspython python-enum34 python-funcsigs python-idna python-ipaddress python-mock python-openssl python-parsedatetime python-pbr python-pkg-resources python-psutil
  164. python-pyasn1 python-pyicu python-requests python-rfc3339 python-setuptools python-six python-tz python-urllib3 python-zope.component python-zope.event
  165. python-zope.hookable python-zope.interface
  166. etc...
  167. </code></pre>
  168. <h2 id="creation-des-certificats-pour-nos-domaines">Création des certificats pour nos domaines</h2>
  169. <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>
  170. <ul>
  171. <li>yojik.net</li>
  172. <li>www.yojik.net</li>
  173. <li>atom.yojik.net</li>
  174. </ul>
  175. <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>
  176. <p>Lors de l'installation de notre webmail, nous rajouterons le domaine correspondant.</p>
  177. <p>Nous ajoutons ici la référence du serveur web, avec un enregistrement CNAME: www.yojik.eu</p>
  178. <pre><code>www IN CNAME atom.yojik.net.
  179. </code></pre>
  180. <p>Relecture des fichiers de configuration par bind:</p>
  181. <pre><code>root@atom:/home/ericadmin# service bind9 reload
  182. </code></pre>
  183. <h2 id="lancement-du-programme-certbot">lancement du programme certbot</h2>
  184. <pre><code>root@atom:/home/ericadmin# certbot --apache
  185. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  186. Which names would you like to activate HTTPS for?
  187. -
  188. 1: yojik.net
  189. 2: www.yojik.net
  190. -
  191. Select the appropriate numbers separated by commas and/or spaces, or leave input
  192. blank to select all options shown (Enter 'c' to cancel):1 2
  193. Obtaining a new certificate
  194. Performing the following challenges:
  195. Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA.
  196. Client with the currently selected authenticator does not support any combination of challenges that will satisfy the CA.
  197. </code></pre>
  198. <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>
  199. <ul>
  200. <li>
  201. <p>Voici le lien:</p>
  202. <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>
  203. </li>
  204. <li>
  205. <p>Ajout des backports dans la liste des dépots:</p>
  206. <p>Il nous faut ajouter dans /etc/sources.list le dépot <strong>backports</strong> pour obtenir le fichier qui suit:</p>
  207. <p>Lien: <a href="https://backports.debian.org/Instructions/">Installation des backports</a></p>
  208. <p>Voici le contenu du fichier <em>etc/apt/sources.list</em></p>
  209. <pre><code>root@atom:/home/ericadmin# cat /etc/apt/sources.list
  210. #
  211. # deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main
  212. #deb cdrom:[Debian GNU/Linux 9.3.0 _Stretch_ - Official amd64 NETINST 20171209-12:10]/ stretch main
  213. deb http://deb.debian.org/debian/ stretch main contrib
  214. deb-src http://deb.debian.org/debian/ stretch main contrib
  215. deb http://security.debian.org/debian-security stretch/updates main contrib
  216. deb-src http://security.debian.org/debian-security stretch/updates main contrib
  217. # stretch-updates, previously known as 'volatile'
  218. deb http://deb.debian.org/debian/ stretch-updates main contrib
  219. deb-src http://deb.debian.org/debian/ stretch-updates main contrib
  220. deb http://ftp.debian.org/debian stretch-backports main contrib
  221. </code></pre>
  222. <p>Notez la dernière ligne rajoutée au fichier. Ensuite,entrez les commandes suivantes:</p>
  223. <pre><code>apt update
  224. apt-get install python-certbot-apache -t stretch-backports
  225. </code></pre>
  226. <p>Un grand nombre de paquets vont être installés ...</p>
  227. </li>
  228. </ul>
  229. <p>On relance le programme certbot:</p>
  230. <pre><code>certbot --apache
  231. </code></pre>
  232. <p>Cette fois-ci, ça fonctionne.</p>
  233. <pre><code>root@atom:/home/ericadmin# certbot --apache
  234. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  235. Plugins selected: Authenticator apache, Installer apache
  236. Which names would you like to activate HTTPS for?
  237. -
  238. 1: yojik.net
  239. 2: www.yojik.net
  240. -
  241. Select the appropriate numbers separated by commas and/or spaces, or leave input
  242. blank to select all options shown (Enter 'c' to cancel): 1
  243. Obtaining a new certificate
  244. Performing the following challenges:
  245. http-01 challenge for yojik.net
  246. Waiting for verification...
  247. Cleaning up challenges
  248. Created an SSL vhost at /etc/apache2/sites-available/yojiknet-le-ssl.conf
  249. Deploying Certificate to VirtualHost /etc/apache2/sites-available/yojiknet-le-ssl.conf
  250. Enabling available site: /etc/apache2/sites-available/yojiknet-le-ssl.conf
  251. Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
  252. -
  253. 1: No redirect - Make no further changes to the webserver configuration.
  254. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
  255. new sites, or if you're confident your site works on HTTPS. You can undo this
  256. change by editing your web server's configuration.
  257. -
  258. Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
  259. Redirecting vhost in /etc/apache2/sites-enabled/yojiknet.conf to ssl vhost in /etc/apache2/sites-available/yojiknet-le-ssl.conf
  260. -
  261. Congratulations! You have successfully enabled https://yojik.net
  262. You should test your configuration at:
  263. https://www.ssllabs.com/ssltest/analyze.html?d=yojik.net
  264. -
  265. IMPORTANT NOTES:
  266. - Congratulations! Your certificate and chain have been saved at:
  267. /etc/letsencrypt/live/yojik.net/fullchain.pem
  268. Your key file has been saved at:
  269. /etc/letsencrypt/live/yojik.net/privkey.pem
  270. Your cert will expire on 2018-08-19. To obtain a new or tweaked
  271. version of this certificate in the future, simply run certbot again
  272. with the "certonly" option. To non-interactively renew *all* of
  273. your certificates, run "certbot renew"
  274. - If you like Certbot, please consider supporting our work by:
  275. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  276. Donating to EFF: https://eff.org/donate-le
  277. root@atom:/home/ericadmin#
  278. </code></pre>
  279. <p>On retape les mêmes commandes pour générer les certificats pour le domaine <strong>www.yojik.net</strong>.</p>
  280. <p>Testez votre configuration comme indiqué ci-dessus. Vous devez obtenir une note <strong>A</strong>.</p>
  281. <p>Il nous faut maintenant créer un certificat pour notre serveur mail:</p>
  282. <pre><code>root@atom:/home/ericadmin# certbot certonly -d atom.yojik.net
  283. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  284. How would you like to authenticate with the ACME CA?
  285. -
  286. 1: Apache Web Server plugin - Beta (apache)
  287. 2: Spin up a temporary webserver (standalone)
  288. 3: Place files in webroot directory (webroot)
  289. -
  290. Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 1
  291. Plugins selected: Authenticator apache, Installer None
  292. Obtaining a new certificate
  293. Performing the following challenges:
  294. http-01 challenge for atom.yojik.net
  295. Waiting for verification...
  296. Cleaning up challenges
  297. IMPORTANT NOTES:
  298. - Congratulations! Your certificate and chain have been saved at:
  299. /etc/letsencrypt/live/atom.yojik.net/fullchain.pem
  300. Your key file has been saved at:
  301. /etc/letsencrypt/live/atom.yojik.net/privkey.pem
  302. Your cert will expire on 2018-08-19. To obtain a new or tweaked
  303. version of this certificate in the future, simply run certbot
  304. again. To non-interactively renew *all* of your certificates, run
  305. "certbot renew"
  306. - If you like Certbot, please consider supporting our work by:
  307. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  308. Donating to EFF: https://eff.org/donate-le
  309. root@atom:/home/ericadmin#
  310. </code></pre>
  311. <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>
  312. </div>
  313. </div>
  314. <footer>
  315. <hr/>
  316. <div role="contentinfo">
  317. <!-- Copyright etc -->
  318. </div>
  319. 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>.
  320. </footer>
  321. </div>
  322. </div>
  323. </section>
  324. </div>
  325. <div class="rst-versions" role="note" aria-label="versions">
  326. <span class="rst-current-version" data-toggle="rst-current-version">
  327. </span>
  328. </div>
  329. <script>var base_url = '../../..';</script>
  330. <script src="../../../js/theme.js" defer></script>
  331. <script src="../../../search/main.js" defer></script>
  332. <script defer>
  333. window.onload = function () {
  334. SphinxRtdTheme.Navigation.enable(true);
  335. };
  336. </script>
  337. </body>
  338. </html>