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.

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