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.

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