【问题标题】:How to install Certbot (Let's Encrypt) without interaction?如何在没有交互的情况下安装 Certbot (Let's Encrypt)?
【发布时间】:2018-08-16 18:58:17
【问题描述】:

我正在编写一个 bash 脚本,它在新安装的服务器中引导整个项目基础架构,我想使用 letcecrypt certbot 配置 ssl 安装。在我执行行之后:

certbot --nginx -d $( get_server_name ) -d www.$( get_server_name ).com

系统提示我几个问题。 certbot 可以在没有任何交互的情况下运行,同时将一些参数作为参数或其他东西传递吗?

【问题讨论】:

    标签: bash ssl server lets-encrypt certbot


    【解决方案1】:

    您可以通过添加以下选项“静默”运行 certbot:

    --non-interactive --agree-tos -m webmaster@example.com
    

    配置选项的完整列表可在此处获得:

    https://certbot.eff.org/docs/using.html

    【讨论】:

    • 还包括'--domains'
    • 请记住,--non-interactive 不是防故障的,如果缺少 3 个强制性标志,证书仍然无法生成(有关更多信息,请参阅我的答案)。
    • 没用。我收到此错误Missing command line flags. For non-interactive execution, you will need to specify a plugin on the command line. Run with '--help plugins' to see a list of options, and see https://eff.org/letsencrypt-plugins for more detail on what the plugins do and how to use them.
    • 艾哈迈德,您缺少--apache,或--nginx,或您正在使用的任何服务器。顺便说一句,我发现“还包括 --domains”评论不够充分 - 我不清楚服务器名称是否需要跟在它后面。这是我的完整命令格式,它(使用 root)有效:certbot --nginx --non-interactive --agree-tos --domains example.com --email webmaster@example.com
    • @Ahmed 你能帮我什么意思吗?名称服务器域无法从 Internet 访问,因为有防火墙或过滤路由器阻止 UDP 和 TCP 连接到此主机上的端口 53连接。防火墙配置必须允许 Internet 上任何主机在此端口上的连接,DNS 才能正常运行。
    【解决方案2】:

    Certbot 提供了几个inline flags and "subcommands"(他们的昵称),可以帮助使用 Bash 或 shell 脚本自动生成免费 SSL 证书的过程。

    @match 提到的最相关的标志是:

    • --noninteractive ...或者... --non-interactive

    但实际上这个标志并不是很有帮助,因为它的作用并不大。例如,如果您的脚本中缺少关键标志,证书仍然无法生成。坦率地说,我认为 Certbot 取消上述标志会更好,因为它相当具有误导性。

    以下是所需的最少标志:

    1. --agree-tos
    2. --register-unsafely-without-email ...或... -m username@example.com
    3. -d example.com 和/或 -d www.example.com

    您还必须指定您想要的 Let's Encrypt installer plugin(环境)类型,例如,您可以选择“独立”或“手动”等...对于大多数情况,如 WordPress Web 服务器,您应该选择“webroot”,以便 Certbot 可以通过公共 root 轻松验证所有权(确保对 /.well-known* 的访问未被阻止):

    --webroot -w /var/www/html/
    

    这是我们use in SlickStack 安装 SSL 证书的完整命令:

    ## install Certbot SSL certificate ##
    certbot certonly --noninteractive --agree-tos --cert-name slickstack -d ${SITE_TLD} -d www.${SITE_TLD} -d staging.${SITE_TLD} -d dev.${SITE_TLD} --register-unsafely-without-email --webroot -w /var/www/html/
    

    在我们的例子中,我们将--cert-name 硬编码为slickstack,因为每个 VPS 服务器上只安装了一个网站,因此它使其他服务器管理任务(和脚本)更易于管理。但是,如果您在同一台服务器上安装多个域和 SSL 证书,则可以将子命令 --cert-name 更改为以每个 TLD 域命名,等等。这会影响 SSL 目录名称,从而有助于保留您的文件/文件夹干净整洁。

    【讨论】:

    • 不错 :) certbot certonly --noninteractive --agree-tos --cert-name ${SITE_TLD} -d ${SITE_DOMAIN_ONE} -d ${SITE_DOMAIN_TWO} -m ${SSL_EMAIL} --webroot -w /var/www/html/
    • sudo certbot --noninteractive --agree-tos --no-eff-email --cert-name domain.com --apache --no-redirect -d domain.com -d www。 domain.com -m siteadminsemail@gmail.com
    猜你喜欢
    • 2014-11-17
    • 1970-01-01
    • 2016-12-03
    • 1970-01-01
    • 2017-10-24
    • 2017-05-22
    • 2013-10-16
    • 1970-01-01
    • 2017-04-12
    相关资源
    最近更新 更多