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.

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