index.html 20 KB

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