certbot 命令+ certbot_dns_aliyun 插件申请泛域名证书
雷恩
阅读:1012
2024-10-29 16:12:31
评论:0
安装 certbot
我的环境是Ubuntu 22.04 ,这里就以此为例展示安装步骤了。
apt install certbot -y 或者通过pip 安装,我这里是通过pip来安装的 root@ikuai-ubuntu:~# python3.10 -m pip install certbot Collecting certbot Downloading certbot-2.11.0-py3-none-any.whl (407 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 407.3/407.3 KB 19.7 kB/s eta 0:00:00 Collecting configobj>=5.0.6 Downloading configobj-5.0.9.tar.gz (101 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.5/101.5 KB 11.5 kB/s eta 0:00:00 ..... Building wheels for collected packages: configobj Building wheel for configobj (pyproject.toml) ... done Created wheel for configobj: filename=configobj-5.0.9-py2.py3-none-any.whl size=35633 sha256=93569d4e50b358a34925740148bfd01f1b68639b23bc2611af60ef855f12455d Stored in directory: /root/.cache/pip/wheels/9d/a5/28/f7e792d399ef0f3bfc34f7e42ac5078547f73936484eb3ae02 Successfully built configobj Installing collected packages: parsedatetime, pycparser, configobj, ConfigArgParse, cffi, cryptography, PyOpenSSL, josepy, acme, certbot Attempting uninstall: cryptography Found existing installation: cryptography 3.4.8 Not uninstalling cryptography at /usr/lib/python3/dist-packages, outside environment /usr Can't uninstall 'cryptography'. No files were found to uninstall. Successfully installed ConfigArgParse-1.7 PyOpenSSL-24.2.1 acme-2.11.0 certbot-2.11.0 cffi-1.17.1 configobj-5.0.9 cryptography-43.0.3 josepy-1.14.0 parsedatetime-2.6 pycparser-2.22 其他的就省略了 root@ikuai-ubuntu:~# cerbot --version certbot 2.11.0 #可以查看是否安装成功 默认certbot bin文件在/usr/local/bin/certbot
查看现有的插件
可以看到,只有2个插件。
root@ikuai-ubuntu:~# certbot plugins Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * standalone Description: Runs an HTTP server locally which serves the necessary validation files under the /.well-known/acme-challenge/ request path. Suitable if there is no HTTP server already running. HTTP challenge only (wildcards not supported). Interfaces: Authenticator, Plugin Entry point: EntryPoint(name='standalone', value='certbot._internal.plugins.standalone:Authenticator', group='certbot.plugins') * webroot Description: Saves the necessary validation files to a .well-known/acme-challenge/ directory within the nominated webroot path. A seperate HTTP server must be running and serving files from the webroot path. HTTP challenge only (wildcards not supported). Interfaces: Authenticator, Plugin Entry point: EntryPoint(name='webroot', value='certbot._internal.plugins.webroot:Authenticator', group='certbot.plugins') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
安装 certbot_dns_aliyun插件
python3.10 -m pip install certbot_dns_aliyun # 或者手动安装也可以 git clone https://github.com/tengattack/certbot-dns-aliyun cd certbot-dns-aliyun python3.10 setup.py install #上面命令成功后,再次查看certbot 插件,可以看到已经有dns-aliyun的插件了。 root@ikuai-ubuntu:~# certbot plugins Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * dns-aliyun Description: Obtain certificates using a DNS TXT record (if you are using Aliyun DNS). Interfaces: Authenticator, Plugin Entry point: EntryPoint(name='dns-aliyun', value='certbot_dns_aliyun.dns_aliyun:Authenticator', group='certbot.plugins') * standalone Description: Runs an HTTP server locally which serves the necessary validation files under the /.well-known/acme-challenge/ request path. Suitable if there is no HTTP server already running. HTTP challenge only (wildcards not supported). Interfaces: Authenticator, Plugin Entry point: EntryPoint(name='standalone', value='certbot._internal.plugins.standalone:Authenticator', group='certbot.plugins') * webroot Description: Saves the necessary validation files to a .well-known/acme-challenge/ directory within the nominated webroot path. A seperate HTTP server must be running and serving files from the webroot path. HTTP challenge only (wildcards not supported). Interfaces: Authenticator, Plugin Entry point: EntryPoint(name='webroot', value='certbot._internal.plugins.webroot:Authenticator', group='certbot.plugins') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
创建认证文件
root@ikuai-ubuntu:~# vim /root/credentials.ini # 增加AK和SK,需要在阿里云创建RAM Access Key,并确保该账号具有AliyunDNSFullAccess权限 dns_aliyun_access_key =xxxxxx dns_aliyun_access_key_secret =xxxxxx root@ikuai-ubuntu:~# chmod 600 credentials.ini #修改权限避免申请的出现warning的提示,其实不修改也可以,会提示 Unsafe permissions on credentials configuration file: /root/credentials.ini
申请证书
-d 可以申请多个或者*.domain.com,我这里就以www.itxz.cc为例。
root@ikuai-ubuntu:/etc/letsencrypt# python3.10 /usr/local/bin/certbot certonly --authenticator dns-aliyun -d www.itxz.cc --dns-aliyun-credentials /root/credentials.ini --register-unsafely-without-email --agree-tos Saving debug log to /var/log/letsencrypt/letsencrypt.log Requesting a certificate for www.itxz.cc Waiting 30 seconds for DNS changes to propagate Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/www.itxz.cc/fullchain.pem Key is saved at: /etc/letsencrypt/live/www.itxz.cc/privkey.pem This certificate expires on 2025-01-27. These files will be updated when the certificate renews. NEXT STEPS: - The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you like Certbot, please consider supporting our work by: * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate * Donating to EFF: https://eff.org/donate-le - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
以上就代表申请成功了。
本文链接:https://www.itxz.cc/?id=8 转载需授权!
本文 zblog模板 原创,转载保留链接!网址:https://www.itxz.cc/?id=8
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。
