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.

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