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.

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