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.

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