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.

267 lines
10 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. Using the deploy API
  2. ====================
  3. Before you can deploy your cert, you must [issue the cert first].
  4. [issue the cert first]: https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert
  5. Here are the scripts to deploy the certs/key to the server/services:
  6. 1. [Deploy the certs to your cpanel host](#deploy-the-certs-to-your-cpanel-host)
  7. 2. [Deploy ssl cert on kong proxy engine based on API](#deploy-ssl-cert-on-kong-proxy-engine-based-on-api)
  8. 3. [Deploy the cert to remote server through SSH access](#deploy-the-cert-to-remote-server-through-ssh-access)
  9. 4. [Deploy the cert to local vsftpd server](#deploy-the-cert-to-local-vsftpd-server)
  10. 5. [Deploy the cert to local exim4 server](#deploy-the-cert-to-local-exim4-server)
  11. 6. [Deploy the cert to OSX Keychain](#deploy-the-cert-to-osx-keychain)
  12. 7. [Deploy to cpanel host using UAPI](#deploy-to-cpanel-host-using-uapi)
  13. 8. [Deploy the cert to your FRITZ!Box router](#deploy-the-cert-to-your-fritzbox-router)
  14. 9. [Deploy the cert to strongSwan](#deploy-the-cert-to-strongswan)
  15. ------------------------------------------------------------------------
  16. Deploy the certs to your cpanel host
  17. ------------------------------------
  18. If you want to deploy using cpanel UAPI see
  19. [Deploy to cpanel host using UAPI].
  20. (cpanel deploy hook is not finished yet, this is just an example.)
  21. Then you can deploy:
  22. export DEPLOY_CPANEL_USER=myusername
  23. export DEPLOY_CPANEL_PASSWORD=PASSWORD
  24. acme.sh --deploy -d example.com --deploy-hook cpanel
  25. Deploy ssl cert on kong proxy engine based on API
  26. -------------------------------------------------
  27. Before you can deploy your cert, you must [issue the cert first].
  28. Currently supports Kong-v0.10.x.
  29. acme.sh --deploy -d ftp.example.com --deploy-hook kong
  30. Deploy the cert to remote server through SSH access
  31. ---------------------------------------------------
  32. The ssh deploy plugin allows you to deploy certificates to a remote host
  33. using SSH command to connect to the remote server. The ssh plugin is
  34. invoked with the following command:
  35. acme.sh --deploy -d example.com --deploy-hook ssh
  36. Prior to running this for the first time you must tell the plugin where
  37. and how to deploy the certificates. This is done by exporting the
  38. following environment variables. This is not required for subsequent
  39. runs as the values are stored by acme.sh in the domain configuration
  40. files.
  41. Required:
  42. export DEPLOY_SSH_USER=username
  43. Optional:
  44. export DEPLOY_SSH_CMD=custom ssh command
  45. export DEPLOY_SSH_SERVER=url or ip address of remote host
  46. export DEPLOY_SSH_KEYFILE=filename for private key
  47. export DEPLOY_SSH_CERTFILE=filename for certificate file
  48. export DEPLOY_SSH_CAFILE=filename for intermediate CA file
  49. export DEPLOY_SSH_FULLCHAIN=filename for fullchain file
  50. export DEPLOY_SSH_REMOTE_CMD=command to execute on remote host
  51. export DEPLOY_SSH_BACKUP=yes or no
  52. `DEPLOY_SSH_USER`
  53. Username at the remote host that SSH will login with. Note that SSH
  54. must be able to login to remote host without a password. SSH Keys must
  55. have been exchanged with the remote host. Validate and test that you
  56. can login to `USER@URL` from the host running acme.sh before using this
  57. script.
  58. The `USER@URL` at the remote server must also have has permissions to
  59. write to the target location of the certificate files and to execute any
  60. commands (e.g. to stop/start services).
  61. `DEPLOY_SSH_CMD`
  62. You can customize the ssh command used to connect to the remote host.
  63. For example if you need to connect to a specific port at the remote
  64. server you can set this to, for example, "ssh -p 22" or to use `sshpass`
  65. to provide password inline instead of exchanging ssh keys (this is not
  66. recommended, using keys is more secure).
  67. `DEPLOY_SSH_SERVER`
  68. URL or IP Address of the remote server. If not provided then the domain
  69. name provided on the acme.sh --deploy command line is used.
  70. `DEPLOY_SSH_KEYFILE`
  71. Target filename for the private key issued by Let's Encrypt.
  72. `DEPLOY_SSH_CERTFILE`
  73. Target filename for the certificate issued by Let's Encrypt. If this is
  74. the same as the previous filename (for keyfile) then it is appended to
  75. the same file.
  76. `DEPLOY_SSH_CAFILE`
  77. Target filename for the CA intermediate certificate issued by Let's
  78. Encrypt. If this is the same as a previous filename (for keyfile or
  79. certfile) then it is appended to the same file.
  80. `DEPLOY_SSH_FULLCHAIN`
  81. Target filename for the fullchain certificate issued by Let's Encrypt.
  82. If this is the same as a previous filename (for keyfile, certfile or
  83. cafile) then it is appended to the same file.
  84. `DEPLOY_SSH_REMOTE_CMD`
  85. Command to execute on the remote server after copying any certificates.
  86. This could be any additional command required for example to stop and
  87. restart the service.
  88. `DEPLOY_SSH_BACKUP`
  89. Before writing a certificate file to the remote server the existing
  90. certificate will be copied to a backup directory on the remote server.
  91. These are placed in a hidden directory in the home directory of the SSH
  92. user
  93. ~/.acme_ssh_deploy/[domain name]-backup-[timestamp]
  94. Any backups older than 180 days will be deleted when new certificates
  95. are deployed. This defaults to "yes" set to "no" to disable backup.
  96. ### Examples using SSH deploy
  97. The following example illustrates deploying certificates to a QNAP NAS
  98. (tested with QTS version 4.2.3)
  99. export DEPLOY_SSH_USER="admin"
  100. export DEPLOY_SSH_KEYFILE="/etc/stunnel/stunnel.pem"
  101. export DEPLOY_SSH_CERTFILE="/etc/stunnel/stunnel.pem"
  102. export DEPLOY_SSH_CAFILE="/etc/stunnel/uca.pem"
  103. export DEPLOY_SSH_REMOTE_CMD="/etc/init.d/stunnel.sh restart"
  104. acme.sh --deploy -d qnap.example.com --deploy-hook ssh
  105. Note how in this example both the private key and certificate point to
  106. the same file. This will result in the certificate being appended to
  107. the same file as the private key, a common requirement of several
  108. services.
  109. The next example illustrates deploying certificates to a UniFi
  110. Controller (tested with version 5.4.11).
  111. export DEPLOY_SSH_USER="root"
  112. export DEPLOY_SSH_KEYFILE="/var/lib/unifi/unifi.example.com.key"
  113. export DEPLOY_SSH_FULLCHAIN="/var/lib/unifi/unifi.example.com.cer"
  114. export DEPLOY_SSH_REMOTE_CMD="openssl pkcs12 -export \
  115. -inkey /var/lib/unifi/unifi.example.com.key \
  116. -in /var/lib/unifi/unifi.example.com.cer \
  117. -out /var/lib/unifi/unifi.example.com.p12 \
  118. -name ubnt -password pass:temppass \
  119. && keytool -importkeystore -deststorepass aircontrolenterprise \
  120. -destkeypass aircontrolenterprise \
  121. -destkeystore /var/lib/unifi/keystore \
  122. -srckeystore /var/lib/unifi/unifi.example.com.p12 \
  123. -srcstoretype PKCS12 -srcstorepass temppass -alias ubnt -noprompt \
  124. && service unifi restart"
  125. acme.sh --deploy -d unifi.example.com --deploy-hook ssh
  126. In this example we execute several commands on the remote host after the
  127. certificate files have been copied to generate a pkcs12 file compatible
  128. with UniFi, to import it into the UniFi keystore and then finally to
  129. restart the service.
  130. Note also that once the certificate is imported into the keystore the
  131. individual certificate files are no longer required. We could if we
  132. desired delete those files immediately. If we do that then we should
  133. disable backup at the remote host (as there are no files to backup --
  134. they were erased during deployment). For example:
  135. export DEPLOY_SSH_BACKUP=no
  136. # modify the end of the remote command...
  137. && rm /var/lib/unifi/unifi.example.com.key \
  138. /var/lib/unifi/unifi.example.com.cer \
  139. /var/lib/unifi/unifi.example.com.p12 \
  140. && service unifi restart
  141. Deploy the cert to local vsftpd server
  142. --------------------------------------
  143. acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
  144. The default vsftpd conf file is `/etc/vsftpd.conf`, if your vsftpd conf
  145. is not in the default location, you can specify one:
  146. export DEPLOY_VSFTPD_CONF="/etc/vsftpd.conf"
  147. acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
  148. The default command to restart vsftpd server is `service vsftpd
  149. restart`, if it doesn't work, you can specify one:
  150. export DEPLOY_VSFTPD_RELOAD="/etc/init.d/vsftpd restart"
  151. acme.sh --deploy -d ftp.example.com --deploy-hook vsftpd
  152. Deploy the cert to local exim4 server
  153. -------------------------------------
  154. acme.sh --deploy -d ftp.example.com --deploy-hook exim4
  155. The default exim4 conf file is `/etc/exim/exim.conf`, if your exim4 conf
  156. is not in the default location, you can specify one:
  157. export DEPLOY_EXIM4_CONF="/etc/exim4/exim4.conf.template"
  158. acme.sh --deploy -d ftp.example.com --deploy-hook exim4
  159. The default command to restart exim4 server is `service exim4 restart`,
  160. if it doesn't work, you can specify one:
  161. export DEPLOY_EXIM4_RELOAD="/etc/init.d/exim4 restart"
  162. acme.sh --deploy -d ftp.example.com --deploy-hook exim4
  163. Deploy the cert to OSX Keychain
  164. -------------------------------
  165. acme.sh --deploy -d ftp.example.com --deploy-hook keychain
  166. Deploy to cpanel host using UAPI
  167. --------------------------------
  168. This hook is using UAPI and works in cPanel & WHM version 56 or newer.
  169. acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
  170. `DEPLOY_CPANEL_USER` is required only if you run the script as root and
  171. it should contain cpanel username.
  172. export DEPLOY_CPANEL_USER=username
  173. acme.sh --deploy -d example.com --deploy-hook cpanel_uapi
  174. Please note, that the `cpanel_uapi` hook will deploy only the first
  175. domain when your certificate will automatically renew. Therefore you
  176. should issue a separate certificate for each domain.
  177. Deploy the cert to your FRITZ!Box router
  178. ----------------------------------------
  179. You must specify the credentials that have administrative privileges on
  180. the FRITZ!Box in order to deploy the certificate, plus the URL of your
  181. FRITZ!Box, through the following environment variables:
  182. export DEPLOY_FRITZBOX_USERNAME=my_username
  183. export DEPLOY_FRITZBOX_PASSWORD=the_password
  184. export DEPLOY_FRITZBOX_URL=https://fritzbox.example.com
  185. After the first deployment, these values will be stored in your
  186. `$HOME/.acme.sh/account.conf`. You may now deploy the certificate like
  187. this:
  188. acme.sh --deploy -d fritzbox.example.com --deploy-hook fritzbox
  189. Deploy the cert to strongSwan
  190. -----------------------------
  191. acme.sh --deploy -d ftp.example.com --deploy-hook strongswan