0749.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Containerized Self-Hosted ACME Server with Step-CA in Docker</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,ACME,Certificate Authority,Certificates,Encryption,HTTPS,IT Security,Let's Encrypt,Let's Encrypt Alternative,Linux,PKI,Public Key Infrastructure,SSL Certificates,Self-Hosted Let's Encrypt,Self-Signed,Self-Signed HTTPS,Self-Signed PKI,Self-Signed SSL,Container,Containerization,Docker,Docker How To,Docker Made Easy,Docker Tutorial,Docker Installation Tutorial,Docker Simplified,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Containerized Self-Hosted ACME Server with Step-CA in Docker">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="05/14/2023 06:51:16 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Containerized Self-Hosted ACME Server with Step-CA in Docker</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>What is Step-CA?</h2>
  26. <blockquote><em>[Step-CA is] a private certificate authority (X.509 &amp; SSH) &amp; ACME server for secure automated certificate management, so you can use TLS everywhere &amp; SSO for SSH. -<a href="https://github.com/smallstep/certificates" target="_blank">https://github.com/smallstep/certificates</a></em></blockquote>
  27. <h2>Installing Docker</h2>
  28. <ol>
  29. <li>Log into the Linux based device</li>
  30. <li>Run the following commands in the terminal
  31. <div class="codeBlock"># install prerequisites<br />
  32. sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y<br />
  33. # add docker gpg key<br />
  34. curl -fsSL https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release)/gpg | sudo apt-key add -<br />
  35. # add docker software repository<br />
  36. sudo add-apt-repository &quot;deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release) $(lsb_release -cs) stable&quot;<br />
  37. # install docker<br />
  38. sudo apt install docker-ce docker-compose containerd.io -y<br />
  39. # enable and start docker service<br />
  40. sudo systemctl enable docker &amp;&amp; sudo systemctl start docker<br />
  41. # add the current user to the docker group<br />
  42. sudo usermod -aG docker $USER<br />
  43. # reauthenticate for the new group membership to take effect<br />
  44. su - $USER</div>
  45. </li>
  46. </ol>
  47. <h2>Running Step-CA Server</h2>
  48. <ol>
  49. <li>Continue with the following commands in a terminal window
  50. <div class="codeBlock"># create a working directory<br />
  51. mkdir ~/docker/step-ca -p<br />
  52. # start the step-ca container<br />
  53. # change the INIT_NAME and DNS_NAMES variables as needed<br />
  54. docker run -d --name=step-ca -v ~/docker/step-ca:/home/step -p 9000:9000 -e DOCKER_STEPCA_INIT_NAME=&quot;i12bretro Certificate Authority&quot; -e DOCKER_STEPCA_INIT_DNS_NAMES=&quot;$(hostname -f)&quot; smallstep/step-ca<br />
  55. # enable the acme provisioner<br />
  56. docker exec -it step-ca step ca provisioner add acme --type ACME<br />
  57. # restart the step-ca container<br />
  58. docker restart step-ca</div>
  59. </li>
  60. </ol>
  61. <h2>Automating Certificate Requests</h2>
  62. <ol>
  63. <li>Log into the server needing to request a certificate</li>
  64. <li>Continue following commands in a terminal window
  65. <div class="codeBlock"># if on a remote server from the docker host, copy the root-ca.crt file<br />
  66. scp &lt;%user%&gt;@&lt;%dockerhostDNSorIP%&gt;:~/docker/step-ca/certs/root_ca.crt ~/root_ca.crt<br />
  67. # remove apt version of certbot if installed<br />
  68. sudo apt remove certbot -y<br />
  69. # install snapd<br />
  70. sudo apt install snapd -y<br />
  71. # install snap core and update<br />
  72. sudo snap install core; sudo snap refresh core<br />
  73. # install certbot snap<br />
  74. sudo snap install --classic certbot<br />
  75. # create certbot symbolic link<br />
  76. sudo ln -s /snap/bin/certbot /usr/bin/certbot<br />
  77. # request the certificate<br />
  78. sudo REQUESTS_CA_BUNDLE=~/root_ca.crt certbot certonly --standalone -d &lt;%host-DNS-name%&gt; --server https://&lt;%step-ca-docker-host%&gt;:9000/acme/acme/directory</div>
  79. </li>
  80. <li>When prompted, enter an email address and agree to the terms of service</li>
  81. <li>Choose whether to share your email and receive emails from certbot</li>
  82. <li>Certbot will output information regarding the location of the certificate files</li>
  83. </ol>
  84. <p>Documentation: <a href="https://hub.docker.com/r/smallstep/step-ca" target="_blank">https://hub.docker.com/r/smallstep/step-ca</a></p>
  85. <p>Sources: <a href="https://certbot.eff.org/instructions?ws=other&amp;os=debianbuster" target="_blank">https://certbot.eff.org/instructions?ws=other&amp;os=debianbuster</a><br />
  86. <a href="https://smallstep.com/docs/tutorials/acme-challenge/" target="_blank">https://smallstep.com/docs/tutorials/acme-challenge/</a></p> </div>
  87. </div>
  88. </body>
  89. </html>