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.

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