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.

109 lines
4.5 KiB

8 years ago
8 years ago
  1. # Using deploy api
  2. Here are the scripts to deploy the certs/key to the server/services.
  3. ## 1. Deploy the certs to your cpanel host.
  4. (cpanel deploy hook is not finished yet, this is just an example.)
  5. Before you can deploy your cert, you must [issue the cert first](https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert).
  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 --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. (TODO)
  15. ## 3. Deploy the cert to remote server through SSH access.
  16. The ssh deploy plugin allows you to deploy certificates to a remote host
  17. using SSH command to connect to the remote server. The ssh plugin is invoked
  18. with the following command...
  19. ```bash
  20. acme.sh --deploy -d example.com --deploy-hook ssh
  21. ```
  22. Prior to running this for the first time you must tell the plugin where
  23. and how to deploy the certificates. This is done by exporting the following
  24. environment variables. This is not required for subsequent runs as the
  25. values are stored by acme.sh in the domain configuration files.
  26. Required...
  27. ```bash
  28. export ACME_DEPLOY_SSH_USER="admin"
  29. ```
  30. Optional...
  31. ```bash
  32. export ACME_DEPLOY_SSH_SERVER="qnap"
  33. export ACME_DEPLOY_SSH_PORT="22"
  34. export ACME_DEPLOY_SSH_SERVICE_STOP=""
  35. export ACME_DEPLOY_SSH_KEYFILE="/etc/stunnel/stunnel.pem"
  36. export ACME_DEPLOY_SSH_CERTFILE="/etc/stunnel/stunnel.pem"
  37. export ACME_DEPLOY_SSH_CAFILE="/etc/stunnel/uca.pem"
  38. export ACME_DEPLOY_SSH_FULLCHAIN=""
  39. export ACME_DEPLOY_SSH_REMOTE_CMD="/etc/init.d/stunnel.sh restart"
  40. export ACME_DEPLOY_SSH_SERVICE_START=""
  41. ```
  42. The values used above are illustrative only and represent those that could
  43. be used to deploy certificates to a QNAP NAS device running QTS 4.2
  44. ###ACME_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. ###ACME_DEPLOY_SSH_SERVER
  53. URL or IP Address of the remote server. If not provided then the domain
  54. name provided on the acme.sh --deploy command line is used.
  55. ###ACME_DEPLOY_SSH_PORT
  56. Port number that SSH will attempt to connect to at the remote server. If
  57. not provided then defaults to 22.
  58. ###ACME_DEPLOY_SSH_SERVICE_STOP
  59. Command to execute on the remote server prior to copying any certificates. This
  60. would typically be used to stop the service for which the certificates are
  61. being deployed.
  62. ###ACME_DEPLOY_SSH_KEYFILE
  63. Target filename for the private key issued by LetsEncrypt.
  64. ###ACME_DEPLOY_SSH_CERTFILE
  65. Target filename for the certificate issued by LetsEncrypt. If this filename
  66. is the same as that provided for ACME_DEPLOY_SSH_KEYFILE then this certificate
  67. is appended to the same file as the private key.
  68. ###ACME_DEPLOY_SSH_CAFILE
  69. Target filename for the CA intermediate certificate issued by LetsEncrypt.
  70. ###ACME_DEPLOY_SSH_FULLCHAIN
  71. Target filename for the fullchain certificate issued by LetsEncrypt.
  72. ###ACME_DEPLOY_SSH_REMOTE_CMD
  73. Command to execute on the remote server after copying any certificates. This
  74. could be any additional command required prior to starting the service again,
  75. or could be a all-inclusive restart (stop and start of service). If
  76. ACME_DEPLOY_SSH_SERVICE_STOP value was provided then a 2 second sleep is
  77. inserted prior to calling this command to allow the system to stabalize.
  78. ###ACME_DEPLOY_SSH_SERVICE_START
  79. Command to execute on the remote server after copying any certificates. This
  80. would typically be used to stop the service for which the certificates are
  81. being deployed. If ACME_DEPLOY_SSH_SERVICE_STOP or ACME_DEPLOY_SSH_REMOTE_CMD
  82. values were provided then a 2 second sleep is inserted prior to calling
  83. this command to allow the system to stabalize.
  84. ##Backups
  85. Before writing a certificate file to the remote server the existing
  86. certificate will be copied to a backup directory on the remote server.
  87. These are placed in a hidden directory in the home directory of the SSH
  88. user
  89. ```bash
  90. ~/.acme_ssh_deploy/[domain name]-backup-[timestamp]
  91. ```
  92. Any backups older than 180 days will be deleted when new certificates
  93. are deployed.