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.

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