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.

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