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.

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