apache Certbot找不到环境变量凭证

bn31dyow  于 2022-11-25  发布在  Apache
关注(0)|答案(2)|浏览(172)

我有一个运行Apache的AWS EC2示例上的Ubuntu 20.04服务器,我试图使用certbot获取证书,但是我在凭据方面遇到了问题。下面是我运行的命令,后面是错误输出:

user@address:~$ sudo certbot certonly --dns-route53 --dns-route53-propagation-seconds 30 -d mydomain.com -d *.mydomain.com -i apache

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator dns-route53, Installer apache
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for mydomain.com
dns-01 challenge for mydomain.com
Cleaning up challenges
Unable to locate credentials
To use certbot-dns-route53, configure credentials as described at https://boto3.readthedocs.io/en/latest/guide/configuration.html#best-practices-for-configuring-credentials and add the necessary permissions for Route53 access.

我遵循了以下指南:

  1. https://certbot.eff.org/lets-encrypt/ubuntufocal-apache.html(通配符选项卡,直到步骤6)
  2. https://certbot-dns-route53.readthedocs.io/en/stable/(创建IAM策略并将其应用于新用户)
    并选择使用环境变量设置凭据:
$ export AWS_ACCESS_KEY_ID=<id>
$ export AWS_SECRET_ACCESS_KEY=<secret>

当我使用$ printenv AWS_ACCESS_KEY_ID$ printenv AWS_SECRET_ACCESS_KEY时,屏幕上显示了凭据,所以我不明白为什么certbot无法找到它们。
有什么想法吗?

frebpwbc

frebpwbc1#

通过将certbot命令作为sudo运行,将不再设置环境变量。
连接到sudo su,然后导出变量并运行,或者使用凭据文件查看,以允许该命令访问IAM密钥和IAM机密。
更多信息可用here

snz8szmq

snz8szmq2#

因为您使用sudo来执行命令,正如您在上面提供的那样(此处再次提供它以供参考):

sudo certbot certonly --dns-route53 --dns-route53-propagation-seconds 30 -d mydomain.com -d *.mydomain.com -i apache

然后使用用户root的环境变量和主目录,而不是当前登录用户的环境变量和主目录。因此,您必须确保您的设置是针对root用户的。
在我的例子中,我更喜欢使用配置文件而不是环境变量。由于sudo,这个配置文件的路径和名称是 ~/.aws/config,其内容是:

[default]
aws_access_key_id=<YOUR ACCESS KEY TO AWS>
aws_secret_access_key=<YOUR SECRET ACCESS KEY TO AWS>

更多详情here
现在,Linux中的根home目录很可能是 /root,所以我将从这里开始。详细信息here

相关问题