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.

232 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
  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 alias : `le.sh=~/.le/le.sh` and `le=~/.le/le.sh`.
  26. * create everyday cron job to check and renew the cert if needed.
  27. After install, you must close current terminal and reopen again to make the alias take effect.
  28. Ok, you are ready to issue cert now.
  29. Show help message:
  30. ```
  31. root@v1:~# le.sh
  32. https://github.com/Neilpang/le
  33. v1.1.1
  34. Usage: le.sh [command] ...[args]....
  35. Avalible commands:
  36. install:
  37. Install le.sh to your system.
  38. issue:
  39. Issue a cert.
  40. installcert:
  41. Install the issued cert to apache/nginx or any other server.
  42. renew:
  43. Renew a cert.
  44. renewAll:
  45. Renew all the certs.
  46. uninstall:
  47. Uninstall le.sh, and uninstall the cron job.
  48. version:
  49. Show version info.
  50. installcronjob:
  51. Install the cron job to renew certs, you don't need to call this. The 'install' command can automatically install the cron job.
  52. uninstallcronjob:
  53. Uninstall the cron job. The 'uninstall' command can do this automatically.
  54. createAccountKey:
  55. Create an account private key, professional use.
  56. createDomainKey:
  57. Create an domain private key, professional use.
  58. createCSR:
  59. Create CSR , professional use.
  60. root@v1:~/le# le issue
  61. Usage: le issue webroot|no|apache|dns a.com [www.a.com,b.com,c.com]|no [key-length]|no
  62. ```
  63. Set the param value to "no" means you want to ignore it.
  64. For example, if you give "no" to "key-length", it will use default length 2048.
  65. And if you give 'no' to 'cert-file-path', it will not copy the issued cert to the "cert-file-path".
  66. In all the cases, the issued cert will be placed in "~/.le/domain.com/"
  67. # Just issue a cert:
  68. ```
  69. le issue /home/wwwroot/aa.com aa.com www.aa.com,cp.aa.com
  70. ```
  71. First argument `/home/wwwroot/aa.com` is the web root folder, You must have `write` access to this folder.
  72. Second argument "aa.com" is the main domain you want to issue cert for.
  73. Third argument is the additional domain list you want to use. Comma separated list, which is Optional.
  74. You must point and bind all the domains to the same webroot dir:`/home/wwwroot/aa.com`
  75. The cert will be placed in `~/.le/aa.com/`
  76. The issued cert will be renewed every 80 days automatically.
  77. # Install issued cert to apache/nginx etc.
  78. ```
  79. 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"
  80. ```
  81. Install the issued cert/key to the production apache or nginx path.
  82. 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`
  83. # Use Standalone server to issue cert( requires you be root/sudoer, or you have permission to listen tcp 80 port):
  84. Same usage as all above, just give `no` as the webroot.
  85. The tcp `80` port must be free to listen, otherwise you will be prompted to free the `80` port and try again.
  86. ```
  87. le issue no aa.com www.aa.com,cp.aa.com
  88. ```
  89. # Use Apache mode(requires you be root/sudoer, since it is required to interact with apache server):
  90. If you are running a web server, apache or nginx, it is recommended to use the Webroot mode.
  91. 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.
  92. Just set string "apache" to the first argument, it will use apache plugin automatically.
  93. ```
  94. le issue apache aa.com www.aa.com,user.aa.com
  95. ```
  96. All the other arguments are the same with previous.
  97. # Use DNS mode:
  98. Support the latest dns-01 challenge.
  99. ```
  100. le issue dns aa.com www.aa.com,user.aa.com
  101. ```
  102. You will get the output like bellow:
  103. ```
  104. Add the following txt record:
  105. Domain:_acme-challenge.aa.com
  106. Txt value:9ihDbjYfTExAYeDs4DBUeuTo18KBzwvTEjUnSwd32-c
  107. Add the following txt record:
  108. Domain:_acme-challenge.www.aa.com
  109. Txt value:9ihDbjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  110. ```
  111. Please add those txt records to the domains. Waiting for the dns to take effect.
  112. Then just retry with 'renew' command:
  113. ```
  114. le renew aa.com
  115. ```
  116. Ok, it's finished.
  117. # Use CloudFlare domain api to automatically issue cert
  118. For now, we support clourflare integeration.
  119. First you need to login to your clourflare account to get your api key.
  120. ```
  121. export CF_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
  122. export CF_Email="xxxx@sss.com"
  123. ```
  124. Ok, let's issue cert now:
  125. ```
  126. le.sh issue dns-cf aa.com www.aa.com
  127. ```
  128. The `CF_Key` and `CF_Email` will be saved in `~/.le/account.conf`, when next time you use cloudflare api, it will reuse this key.
  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.