index.html 21 KB

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