NAT VPS申请SSL证书

0. 前言

主要介绍使用acme.sh结合DNS验证方式在NAT VPS上完成证书申请工作。

准备一个域名,例如test.geektech.top,并托管到Cloudflare,关闭小云朵。

1. acme.sh申请证书

1.1 首先安装acme.sh

  • curl https://get.acme.sh | sh

1.2 申请证书

 

  • ~/.acme.sh/acme.sh –issue -d test.geektech.top –dns –yes-I-know-dns-manual-mode-enough-go-ahead-please

请把命令中的 test.geektech.top 换成你自己的域名。

 

命令会有类似如下输出:

  • Add the following TXT record:
  • Domain: ‘_acme-challenge.test.geektech.top’
  • TXT value: ‘NFDSHA8R45321-FHDSGF82fa3hAsd4581

1.3 Cloudflare解析

 

复制上图方框的部分,在域名DNS解析后台添加一条TXT记录。下图是Cloudflare的操作步骤:

添加记录后,建议等两分钟,然后在服务器上执行下面命令完成证书申请:

  • ~/.acme.sh/acme.sh –renew -d test.geektech.top –yes-I-know-dns-manual-mode-enough-go-ahead-please

同样的,请把命令中的 test.geektech.top 换成你自己的域名。

2. 证书安装

DNS解析正确的话,证书就申请好了,放在 /root/.acme.sh/你的域名/ 文件夹下。

# 注意:下面命令中的 test.geektech.top 请换成你自己的域名!

# 如果接下来要运行v2ray一键脚本

  • cp ~/.acme.sh/test.geektech.top/test.geektech.top.key ~/v2ray.key
  • cp ~/.acme.sh/test.geektech.top/fullchain.cer ~/v2ray.pem

# 如果接下来要运行xray一键脚本

  • cp ~/.acme.sh/test.geektech.top/test.geektech.top.key ~/xray.key
  • cp ~/.acme.sh/test.geektech.top/fullchain.cer ~/xray.pem

# 如果接下来要运行trojan一键脚本

  • cp ~/.acme.sh/test.geektech.top/test.geektech.top.key ~/trojan.key
  • cp ~/.acme.sh/test.geektech.top/fullchain.cer ~/trojan.pem

# 如果接下来要运行trojan-go一键脚本

  • cp ~/.acme.sh/test.geektech.top/test.geektech.top.key ~/trojan-go.key
  • cp ~/.acme.sh/test.geektech.top/fullchain.cer ~/trojan-go.pem

到此,证书已经准备好了。

接下来,放心的运行X-ui一键脚本等需要证书的脚本,即使域名解析没指向VPS都没问题

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注