<a href="https://opencollective.com/acmesh" alt="Open Collective上的财务贡献者"><img src="https://yellow-cdn.veclightyear.com/835a84d5/e402c920-80aa-4d08-ad89-22944bed1570.svg?label=financial+contributors" /></a>
这可能是最简单、最智能的自动签发和续期免费证书的Shell脚本。
Wiki:https://github.com/acmesh-official/acme.sh/wiki
Docker爱好者:acme.sh :two_hearts: Docker
Twitter:@neilpangxa
| 序号 | 状态 | 平台 |
|---|---|---|
| 1 | Mac OSX | |
| 2 | Windows(包含cygwin、curl、openssl和crontab) | |
| 3 | FreeBSD | |
| 4 | Solaris | |
| 5 | Ubuntu | |
| 6 | 不适用 | pfsense |
| 7 | OpenBSD | |
| 8 | NetBSD | |
| 9 | DragonFlyBSD | |
| 10 | Omnios | |
| 11 | Debian | |
| 12 | CentOS | |
| 13 | openSUSE | |
| 14 | Alpine Linux(包含curl) | |
| 15 | Archlinux | |
| 16 | Fedora | |
| 17 | Kali Linux | |
| 18 | Oracle Linux | |
| 19 | Mageia | |
| 20 | Gentoo Linux | |
| 21 | ClearLinux | |
| 22 | ----- | Cloud Linux https://github.com/acmesh-official/acme.sh/issues/111 |
| 23 | ----- | OpenWRT:已测试并可用。请参阅wiki页面 |
| 24 | Proxmox:请参阅Proxmox VE维基。4.x、5.0、5.1版本,5.2及更高版本 | |
| 查看我们的测试项目: |
https://github.com/acmesh-official/acmetest
查看此项目:https://github.com/acmesh-official/get.acme.sh
curl https://get.acme.sh | sh -s email=my@example.com
或:
wget -O - https://get.acme.sh | sh -s email=my@example.com
克隆此项目并启动安装:
git clone https://github.com/acmesh-official/acme.sh.git cd ./acme.sh ./acme.sh --install -m my@example.com
你不必是 root 用户,尽管推荐使用 root。
高级安装:https://github.com/acmesh-official/acme.sh/wiki/How-to-install
安装程序将执行 3 个操作:
acme.sh 到你的主目录($HOME):~/.acme.sh/。
所有证书也将放在这个文件夹中。acme.sh=~/.acme.sh/acme.sh。Cron 条目示例:
0 0 * * * "/home/user/.acme.sh"/acme.sh --cron --home "/home/user/.acme.sh" > /dev/null
安装完成后,你必须关闭当前终端并重新打开,以使别名生效。
好了,现在你可以开始颁发证书了。
显示帮助信息:
root@v1:~# acme.sh -h
示例 1: 单域名。
acme.sh --issue -d example.com -w /home/wwwroot/example.com
或:
acme.sh --issue -d example.com -w /home/username/public_html
或:
acme.sh --issue -d example.com -w /var/www/html
示例 2: 在同一证书中包含多个域名。
acme.sh --issue -d example.com -d www.example.com -d cp.example.com -w /home/wwwroot/example.com
参数 /home/wwwroot/example.com 或 /home/username/public_html 或 /var/www/html 是你存放网站文件的网站根目录。你必须对这个文件夹有写入权限。
第二个参数 "example.com" 是你想要为其颁发证书的主域名。 你必须至少有一个域名。
你必须将所有域名指向并绑定到同一个网站根目录:/home/wwwroot/example.com。
证书将被放置在 ~/.acme.sh/example.com/ 中。
证书将每 60 天自动续期一次。
更多示例:https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
生成证书后,你可能想要将证书安装/复制到你的 Apache/Nginx 或其他服务器。 你必须使用此命令将证书复制到目标文件,不要直接使用 ~/.acme.sh/ 文件夹中的证书文件,它们仅供内部使用,文件夹结构将来可能会改变。
Apache 示例:
acme.sh --install-cert -d example.com \ --cert-file /path/to/certfile/in/apache/cert.pem \ --key-file /path/to/keyfile/in/apache/key.pem \ --fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \ --reloadcmd "service apache2 force-reload"
Nginx 示例:
acme.sh --install-cert -d example.com \ --key-file /path/to/keyfile/in/nginx/key.pem \ --fullchain-file /path/to/fullchain/nginx/cert.pem \ --reloadcmd "service nginx force-reload"
只有域名是必需的,所有其他参数都是可选的。
现有文件的所有权和权限信息将被保留。你可以预先创建文件以定义所有权和权限。
将证书/密钥安装/复制到生产环境的 Apache 或 Nginx 路径。
证书默认每 60 天续期一次(可配置)。一旦证书续期,Apache/Nginx 服务将通过命令自动重新加载:service apache2 force-reload 或 service nginx force-reload。
请注意:reloadcmd 非常重要。证书可以自动续期,但如果没有正确的 'reloadcmd',证书可能不会刷新到你的服务器(如 nginx 或 apache),那么你的网站在 60 天后将无法显示续期的证书。
(需要你是 root/sudoer 用户或有权限监听 80 端口(TCP))
端口 80(TCP)必须空闲以供监听,否则你将被提示释放它并重试。
acme.sh --issue --standalone -d example.com -d www.example.com -d cp.example.com
更多示例:https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
(需要你是 root/sudoer 用户或有权限监听 443 端口(TCP))
端口 443(TCP)必须空闲以供监听,否则你将被提示释放它并重试。
acme.sh --issue --alpn -d example.com -d www.example.com -d cp.example.com
更多示例:https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
(需要您是 root/sudoer 用户,因为需要与 Apache 服务器交互)
如果您正在运行 Web 服务器,建议使用 Webroot 模式。
特别是,如果您正在运行 Apache 服务器,可以使用 Apache 模式。这种模式不会向您的 Web 根目录写入任何文件。
只需将字符串 "apache" 作为第二个参数,它将自动强制使用 apache 插件。
acme.sh --issue --apache -d example.com -d www.example.com -d cp.example.com
这种 apache 模式仅用于颁发证书,不会更改您的 apache 配置文件。 您需要自行配置网站配置文件以使用证书。 我们不想干扰您的 apache 服务器,请放心。
更多示例: https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
(需要您是 root/sudoer 用户,因为需 要与 Nginx 服务器交互)
如果您正在运行 Web 服务器,建议使用 Webroot 模式。
特别是,如果您正在运行 nginx 服务器,可以使用 nginx 模式。这种模式不会向您的 Web 根目录写入任何文件。
只需将字符串 "nginx" 作为第二个参数。
它将自动配置 nginx 服务器以验证域名,然后将 nginx 配置恢复到原始版本。
因此,配置不会改变。
acme.sh --issue --nginx -d example.com -d www.example.com -d cp.example.com
这种 nginx 模式仅用于颁发证书,不会更改您的 nginx 配置文件。 您需要自行配置网站配置文件以使用证书。 我们不想干扰您的 nginx 服务器,请放心。
更多示例: https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
如果您的 DNS 提供商支持 API 访问,我们可以使用该 API 自动颁发证书。
您无需手动操作!
https://github.com/acmesh-official/acme.sh/wiki/dnsapi
首先参见: https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode。
如果您的 DNS 提供商不支持任何 API 访问,您可以手动添加 txt 记录。
acme.sh --issue --dns -d example.com -d www.example.com -d cp.example.com
您应该会得到类似以下的输出:
添加以下 txt 记录: 域名:_acme-challenge.example.com Txt 值:9ihDbjYfTExAYeDs4DBUeuTo18KBzwvTEjUnSwd32-c 添加以下 txt 记录: 域名:_acme-challenge.www.example.com Txt 值:9ihDbjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 请将这些 txt 记录添加到域名中。等待 DNS 生效。
然后只需使用 renew 参数重新运行:
acme.sh --renew -d example.com
好了,完成了。
注意,这是 DNS 手动模式,无法自动续期。当您续期证书时,需要手动为域名添加新的 txt 记录。
请改用 DNS API 模式。
只需在 keylength 参数前加上 ec- 前缀。
例如:
acme.sh --issue -w /home/wwwroot/example.com -d example.com --keylength ec-256
acme.sh --issue -w /home/wwwroot/example.com -d example.com -d www.example.com --keylength ec-256
请注意上面的 keylength 参数。
有效值为:
很简单,只需将通配符域名作为 -d 参数即可。
acme.sh --issue -d example.com -d '*.example.com' --dns dns_cf
不,您不需要手动续期证书。所有证书将每 60 天自动续期一次。
但是,您也可以强制续期证书:
acme.sh --renew -d example.com --force
或者,对于 ECC 证书:
acme.sh --renew -d example.com --force --ecc
要停止续期证书,您可以执行以下操作将证书从续期列表中删除:
acme.sh --remove -d example.com [--ecc]
证书/密钥文件不会从磁盘中删除。
您可以自行删除相应的目录(例如 ~/.acme.sh/example.com)。
acme.shacme.sh 正在不断开发中,因此强烈建议使用最新代码。
您可以将 acme.sh 更新到最新代码:
acme.sh --upgrade
您还可以启用自动升级:
acme.sh --upgrade --auto-upgrade
然后 acme.sh 将自动保持最新状态。
禁用自动升级:
acme.sh --upgrade --auto-upgrade 0
https://github.com/acmesh-official/acme.sh/wiki/Issue-a-cert-from-existing-CSR
https://github.com/acmesh-official/acme.sh/wiki/notify
使用 shell 直接与 "Let's Encrypt" 通信 ACME 语言。
待完成:
这个项目的存在要感谢所有做出贡献的人。 <a href="https://github.com/acmesh-official/acme.sh/graphs/contributors"><img src="https://yellow-cdn.veclightyear.com/835a84d5/7a15e140-da6e-4b08-95cb-d4a136c06ce3.svg?width=890&button=false" /></a>
成为财务贡献者,帮助我们维持我们的社区 。[贡献]
<a href="https://opencollective.com/acmesh"><img src="https://yellow-cdn.veclightyear.com/835a84d5/40fe9a46-ddde-4c70-8f1a-3a70534d9709.svg?width=890"></a>
通过您的组织支持这个项目。您的logo将会在这里显示,并链接到您的网站。[贡献]
<a href="https://opencollective.com/acmesh/organization/0/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/2ed30ceb-6661-4fc4-8743-4fddd97e8a4e.svg"></a> <a href="https://opencollective.com/acmesh/organization/1/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/dad97b16-7887-41f9-aa6a-fb558bce80b9.svg"></a> <a href="https://opencollective.com/acmesh/organization/2/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/00ce3e28-1051-4fd0-886c-7632a2ff9050.svg"></a> <a href="https://opencollective.com/acmesh/organization/3/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/c0bd60d8-195c-4a38-8b87-03a70a35b86e.svg"></a> <a href="https://opencollective.com/acmesh/organization/4/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/6e27a80c-f8a3-48fe-9af7-4d29392047b6.svg"></a> <a href="https://opencollective.com/acmesh/organization/5/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/617f6471-99ba-4fb4-94d1-99d24b87b289.svg"></a> <a href="https://opencollective.com/acmesh/organization/6/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/7f6e9bc5-1749-4bb5-8bfd-b48ce7bc278b.svg"></a> <a href="https://opencollective.com/acmesh/organization/7/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/5d5f1a66-8a11-4d02-9e92-29fa4a92ed02.svg"></a> <a href="https://opencollective.com/acmesh/organization/8/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/a889bf71-17a0-4870-a109-fa1db1e8ff61.svg"></a> <a href="https://opencollective.com/acmesh/organization/9/website"><img src="https://yellow-cdn.veclightyear.com/835a84d5/9db1a1df-7989-443f-ac75-a895872c92f0.svg"></a>
许可证为GPLv3
请为我点星和fork。
您的捐赠可以让acme.sh变得更好:


职场AI,就用扣子
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!


多风格AI绘画神器
堆友平台由阿里巴巴设计团队创建,作为一款AI驱动的设计工具,专为设计师提供一站式增长服务。功能覆盖海量3D素材、AI绘画、实时渲染以及专业抠图,显著提升设计品质和效率。平台不仅提供工具,还是一个促进创意交流和个人发展的空间,界面友好,适合所有级别的设计师和创意工作者。


零代码AI应用开发平台
零代码AI应用开发平台,用户只需一句话简单描述需求,AI能自动生成小程序、APP或H5网页应用,无需编写代码。


免费创建高清无水印Sora视频
Vora是一个免费创建高清无水印Sora视频的AI工具


最适合小白的AI自动化工作流平台
无需编码,轻松生成可复用、可变现的AI自动化工作流

大模型驱动的Excel数据处理工具
基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


AI论文写作指导平台
AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。


AI一键生成PPT,就用博思AIPPT!
博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。


AI赋能电商视觉革命,一站式智能商拍平台
潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号