You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
6.3 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # le: means simp`Le`
  2. Simplest shell script for LetsEncrypt free Certificate client
  3. Simple and Powerful, you only need 3 minutes to learn.
  4. Pure written in bash, no dependencies to python , acme-tiny or LetsEncrypt official client.
  5. Just one script, to issue, renew your certificates automatically.
  6. Probably it's the smallest&easiest&smartest shell script to automatically issue&renew the free certificates from LetsEncrypt.
  7. Do NOT require to be `root/sudoer`.
  8. #Tested OS
  9. 1. Ubuntu/Debian.
  10. 2. CentOS
  11. 3. Windows (cygwin with curl, openssl and crontab included)
  12. 4. FreeBSD with bash
  13. 5. pfsense with bash and curl
  14. #Supported Mode
  15. 1. Webroot mode
  16. 2. Standalone mode
  17. 3. Apache mode
  18. 4. Dns mode
  19. #How to use
  20. 1. Clone this project: https://github.com/Neilpang/le.git
  21. 2. Install le:
  22. ```
  23. ./le.sh install
  24. ```
  25. You don't have to be root then, although it is recommended.
  26. Which does 3 jobs:
  27. * create and copy `le.sh` to your home dir: `~/.le`
  28. All the certs will be placed in this folder.
  29. * create alias : `le.sh=~/.le/le.sh` and `le=~/.le/le.sh`.
  30. * create everyday cron job to check and renew the cert if needed.
  31. After install, you must close current terminal and reopen again to make the alias take effect.
  32. Ok, you are ready to issue cert now.
  33. Show help message:
  34. ```
  35. root@v1:~# le.sh
  36. https://github.com/Neilpang/le
  37. v1.1.1
  38. Usage: le.sh [command] ...[args]....
  39. Available commands:
  40. install:
  41. Install le.sh to your system.
  42. issue:
  43. Issue a cert.
  44. installcert:
  45. Install the issued cert to apache/nginx or any other server.
  46. renew:
  47. Renew a cert.
  48. renewAll:
  49. Renew all the certs.
  50. uninstall:
  51. Uninstall le.sh, and uninstall the cron job.
  52. version:
  53. Show version info.
  54. installcronjob:
  55. Install the cron job to renew certs, you don't need to call this. The 'install' command can automatically install the cron job.
  56. uninstallcronjob:
  57. Uninstall the cron job. The 'uninstall' command can do this automatically.
  58. createAccountKey:
  59. Create an account private key, professional use.
  60. createDomainKey:
  61. Create an domain private key, professional use.
  62. createCSR:
  63. Create CSR , professional use.
  64. root@v1:~/le# le issue
  65. Usage: le issue webroot|no|apache|dns a.com [www.a.com,b.com,c.com]|no [key-length]|no
  66. ```
  67. Set the param value to "no" means you want to ignore it.
  68. For example, if you give "no" to "key-length", it will use default length 2048.
  69. And if you give 'no' to 'cert-file-path', it will not copy the issued cert to the "cert-file-path".
  70. In all the cases, the issued cert will be placed in "~/.le/domain.com/"
  71. # Just issue a cert:
  72. Example 1:
  73. Only one domain:
  74. ```
  75. le issue /home/wwwroot/aa.com aa.com
  76. ```
  77. Example 2:
  78. Multiple domains in the same cert:
  79. ```
  80. le issue /home/wwwroot/aa.com aa.com www.aa.com,cp.aa.com
  81. ```
  82. First argument `/home/wwwroot/aa.com` is the web root folder, You must have `write` access to this folder.
  83. Second argument "aa.com" is the main domain you want to issue cert for.
  84. Third argument is the additional domain list you want to use. Comma separated list, which is Optional.
  85. You must point and bind all the domains to the same webroot dir:`/home/wwwroot/aa.com`
  86. The cert will be placed in `~/.le/aa.com/`
  87. The issued cert will be renewed every 80 days automatically.
  88. # Install issued cert to apache/nginx etc.
  89. ```
  90. le installcert aa.com /path/to/certfile/in/apache/nginx /path/to/keyfile/in/apache/nginx /path/to/ca/certfile/apache/nginx "service apache2|nginx reload"
  91. ```
  92. Install the issued cert/key to the production apache or nginx path.
  93. The cert will be renewed every 80 days by default (which is configurable), Once the cert is renewed, the apache/nginx will be automatically reloaded by the command: ` service apache2 reload` or `service nginx reload`
  94. # Use Standalone server to issue cert( requires you be root/sudoer, or you have permission to listen tcp 80 port):
  95. Same usage as all above, just give `no` as the webroot.
  96. The tcp `80` port must be free to listen, otherwise you will be prompted to free the `80` port and try again.
  97. ```
  98. le issue no aa.com www.aa.com,cp.aa.com
  99. ```
  100. # Use Apache mode(requires you be root/sudoer, since it is required to interact with apache server):
  101. If you are running a web server, apache or nginx, it is recommended to use the Webroot mode.
  102. Particularly, if you are running an apache server, you can use apache mode instead. Which doesn't write any file to your web root folder.
  103. Just set string "apache" to the first argument, it will use apache plugin automatically.
  104. ```
  105. le issue apache aa.com www.aa.com,user.aa.com
  106. ```
  107. All the other arguments are the same with previous.
  108. # Use DNS mode:
  109. Support the latest dns-01 challenge.
  110. ```
  111. le issue dns aa.com www.aa.com,user.aa.com
  112. ```
  113. You will get the output like bellow:
  114. ```
  115. Add the following txt record:
  116. Domain:_acme-challenge.aa.com
  117. Txt value:9ihDbjYfTExAYeDs4DBUeuTo18KBzwvTEjUnSwd32-c
  118. Add the following txt record:
  119. Domain:_acme-challenge.www.aa.com
  120. Txt value:9ihDbjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  121. ```
  122. Please add those txt records to the domains. Waiting for the dns to take effect.
  123. Then just retry with 'renew' command:
  124. ```
  125. le renew aa.com
  126. ```
  127. Ok, it's finished.
  128. #Automatic dns api integeration
  129. If your dns provider supports api access, we can use api to automatically issue certs.
  130. You don't have do anything manually.
  131. ###Currently we support:
  132. 1. Cloudflare.com api
  133. 2. Dnspod.cn api
  134. 3. Cloudxns.com api
  135. 4. AWS Route 53, see: https://github.com/Neilpang/le/issues/65
  136. More apis are coming soon....
  137. If your dns provider is not in the supported list above, you can write your own script api easily.
  138. For more details: [How to use dns api](dnsapi)
  139. # Issue ECC certificate:
  140. LetsEncrypt now can issue ECDSA certificate.
  141. And we also support it.
  142. Just set the `length` parameter with a prefix `ec-`.
  143. For example:
  144. ```
  145. le issue /home/wwwroot/aa.com aa.com www.aa.com ec-256
  146. ```
  147. Please look at the last parameter above.
  148. Valid values are:
  149. 1. ec-256 (prime256v1, "ECDSA P-256")
  150. 2. ec-384 (secp384r1, "ECDSA P-384")
  151. 3. ec-521 (secp521r1, "ECDSA P-521", which is not supported by letsencrypt yet.)
  152. #Under the Hood
  153. Speak ACME language with bash directly to Let's encrypt.
  154. TODO:
  155. #Acknowledgment
  156. 1. Acme-tiny: https://github.com/diafygi/acme-tiny
  157. 2. ACME protocol: https://github.com/ietf-wg-acme/acme
  158. 3. letsencrypt: https://github.com/letsencrypt/letsencrypt
  159. #License & Other
  160. License is GPLv3
  161. Please Star and Fork me.
  162. Issues and pull requests are welcomed.