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.

87 lines
3.8 KiB

8 years ago
  1. #Using deploy api
  2. #Using the ssh deploy plugin
  3. The ssh deploy plugin allows you to deploy certificates to a remote host
  4. using SSH command to connect to the remote server. The ssh plugin is invoked
  5. with the following command...
  6. ```bash
  7. acme.sh --deploy -d example.com --deploy-hook ssh
  8. ```
  9. Prior to running this for the first time you must tell the plugin where
  10. and how to deploy the certificates. This is done by exporting the following
  11. environment variables. This is not required for subsequent runs as the
  12. values are stored by acme.sh in the domain configuration files.
  13. Required...
  14. ```bash
  15. export ACME_DEPLOY_SSH_USER="admin"
  16. ```
  17. Optional...
  18. ```bash
  19. export ACME_DEPLOY_SSH_SERVER="qnap"
  20. export ACME_DEPLOY_SSH_PORT="22"
  21. export ACME_DEPLOY_SSH_SERVICE_STOP=""
  22. export ACME_DEPLOY_SSH_KEYFILE="/etc/stunnel/stunnel.pem"
  23. export ACME_DEPLOY_SSH_CERTFILE="/etc/stunnel/stunnel.pem"
  24. export ACME_DEPLOY_SSH_CAFILE="/etc/stunnel/uca.pem"
  25. export ACME_DEPLOY_SSH_FULLCHAIN=""
  26. export ACME_DEPLOY_SSH_REMOTE_CMD="/etc/init.d/stunnel.sh restart"
  27. export ACME_DEPLOY_SSH_SERVICE_START=""
  28. ```
  29. The values used above are illustrative only and represent those that could
  30. be used to deploy certificates to a QNAP NAS device running QTS 4.2
  31. ###ACME_DEPLOY_SSH_USER
  32. Username at the remote host that SSH will login with. Note that
  33. SSH must be able to login to remote host without a password... SSH Keys
  34. must have been exchanged with the remote host. Validate and test that you
  35. can login to USER@URL from the host running acme.sh before using this script.
  36. The USER@URL at the remote server must also have has permissions to write to
  37. the target location of the certificate files and to execute any commands
  38. (e.g. to stop/start services).
  39. ###ACME_DEPLOY_SSH_SERVER
  40. URL or IP Address of the remote server. If not provided then the domain
  41. name provided on the acme.sh --deploy command line is used.
  42. ###ACME_DEPLOY_SSH_PORT
  43. Port number that SSH will attempt to connect to at the remote server. If
  44. not provided then defaults to 22.
  45. ###ACME_DEPLOY_SSH_SERVICE_STOP
  46. Command to execute on the remote server prior to copying any certificates. This
  47. would typically be used to stop the service for which the certificates are
  48. being deployed.
  49. ###ACME_DEPLOY_SSH_KEYFILE
  50. Target filename for the private key issued by LetsEncrypt.
  51. ###ACME_DEPLOY_SSH_CERTFILE
  52. Target filename for the certificate issued by LetsEncrypt. If this filename
  53. is the same as that provided for ACME_DEPLOY_SSH_KEYFILE then this certificate
  54. is appended to the same file as the private key.
  55. ###ACME_DEPLOY_SSH_CAFILE
  56. Target filename for the CA intermediate certificate issued by LetsEncrypt.
  57. ###ACME_DEPLOY_SSH_FULLCHAIN
  58. Target filename for the fullchain certificate issued by LetsEncrypt.
  59. ###ACME_DEPLOY_SSH_REMOTE_CMD
  60. Command to execute on the remote server after copying any certificates. This
  61. could be any additional command required prior to starting the service again,
  62. or could be a all-inclusive restart (stop and start of service). If
  63. ACME_DEPLOY_SSH_SERVICE_STOP value was provided then a 2 second sleep is
  64. inserted prior to calling this command to allow the system to stabalize.
  65. ###ACME_DEPLOY_SSH_SERVICE_START
  66. Command to execute on the remote server after copying any certificates. This
  67. would typically be used to stop the service for which the certificates are
  68. being deployed. If ACME_DEPLOY_SSH_SERVICE_STOP or ACME_DEPLOY_SSH_REMOTE_CMD
  69. values were provided then a 2 second sleep is inserted prior to calling
  70. this command to allow the system to stabalize.
  71. ##Backups
  72. Before writing a certificate file to the remote server the existing
  73. certificate will be copied to a backup directory on the remote server.
  74. These are placed in a hidden directory in the home directory of the SSH
  75. user
  76. ```bash
  77. ~/.acme_ssh_deploy/[domain name]-backup-[timestamp]
  78. ```
  79. Any backups older than 180 days will be deleted when new certificates
  80. are deployed.