安裝acme.sh
curl https://get.acme.sh | sh
- acme.sh默認安裝到了當前家目錄。
[root@iZbp17hycbhnayg00ohec9Z ~]# ~/.acme.sh/
[root@iZbp17hycbhnayg00ohec9Z ~]# ll .acme.sh/
total 492
-rw-r--r-- 1 root root 296 Aug 15 14:28 account.conf
-rwxr-xr-x 1 root root 190583 Aug 15 14:28 acme.sh
-rw-r--r-- 1 root root 78 Aug 15 14:10 acme.sh.csh
-rw-r--r-- 1 root root 78 Aug 15 14:10 acme.sh.env
-rw-r--r-- 1 root root 269335 Aug 15 14:28 acme.sh.log
drwxr-xr-x 4 root root 4096 Aug 15 14:12 ca
drwxr-xr-x 2 root root 4096 Aug 15 14:28 deploy
drwxr-xr-x 2 root root 4096 Aug 15 14:28 dnsapi
-rw-r--r-- 1 root root 2777 Aug 15 14:28 http.header
drwxr-xr-x 2 root root 4096 Aug 15 14:28 notify
- 此次安裝,會在crontab創建定時任務。
[root@iZbp17hycbhnayg00ohec9Z ~]# crontab -l
5 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
添加自動DNS驗證
-
需要阿里雲添加子賬號,並授權“管理雲解析權限”,添加API,阿里雲 AK 是使用
阿里雲子賬戶來添加的。
-
其它自動DNS API驗證方法參考:https://github.com/Neilpang/acme.sh/wiki/dnsapi
-
設置阿里雲子賬號環境變量。
[root@iZbp17hycbhnayg00ohec9Z ~]# cat .bashrc
export Ali_Key="xxxx"
export Ali_Secret="xxx"
[root@iZbp17hycbhnayg00ohec9Z ~]# source .bashrc
申請證書
- 申請證書
[root@iZbp17hycbhnayg00ohec9Z ~]# acme.sh --issue --dns dns_ali -d domain.com -d *.domain.com
- 安裝證書
acme.sh --install-cert -d domain.com -d *.domain.com\
--key-file /etc/nginx/sslkey/domain.com.key \
--fullchain-file /etc/nginx/sslkey/domain.com.pem \
--reloadcmd "/etc/init.d/nginx force-reload"
- acme.sh自動更新
[root@iZbp17hycbhnayg00ohec9Z ~]# acme.sh --upgrade --auto-upgrade
[root@iZbp17hycbhnayg00ohec9Z ~]# cat .bashrc
. "/root/.acme.sh/acme.sh.env"
#證書列表
[root@iZbp17hycbhnayg00ohec9Z ~]# acme.sh list
Main_Domain KeyLength SAN_Domains Created Renew
eoecfd.com "" *.domain.com Thu Aug 15 06:13:10 UTC 2019 Mon Oct 14 06:13:10 UTC 2019