Pass#
來自 Electronic Frontier Foundation 的專案
Introduction#
Certbot 是一款免費的開源軟體工具,用於在手動管理的網站上自動使用 Let’s Encrypt 憑證來啟用 HTTPS。
由電子前沿基金會 (EFF) 製作,該基金會是一家位於加利福尼亞州舊金山的 501(c)3 非營利組織,致力於捍衛數字隱私、言論自由和創新。
Install#
先找到使用的網頁伺服器跟要安裝的方式,這裡使用nginx跟pip的方式安裝certbot
安裝系統依賴#
$ sudo apt update
$ sudo apt install python3 python3-dev python3-venv libaugeas-dev gcc刪除舊的certbot(如果有的話)#
$ sudo apt-get remove certbot安裝certbot#
$ sudo /opt/certbot/bin/pip install certbot certbot-nginx準備 Certbot 命令#
在機器上的命令列上執行以下指令,以確保 certbot 命令可以執行。
$ sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot安裝正確的 DNS 外掛程式#
這裡使用cloudflare
$ sudo /opt/certbot/bin/pip install certbot-dns-cloudflare挑戰cloudflare DNS01#
$ mkdir -p ~/.secrets/certbot/
$ cat dns_cloudflare_api_token = {your-token} > ~/.secrets/certbot/cloudflare.ini
$ certbot certonly \
--dns-cloudflare \
--dns-cloudflare-credentials ~/.secrets/certbot/cloudflare.ini \
-d example.com設定自動續訂#
$ echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null確認 Certbot 正常運作#
若要確認您的網站已正確設定,請在瀏覽器中造訪 https://yourwebsite.com/ 並在 URL 列中尋找鎖定圖示。
[每月]升級 certbot#
偶爾更新 Certbot 以使其保持最新狀態非常重要。若要這樣做,請在電腦上的命令列上執行下列命令。
$ sudo /opt/certbot/bin/pip install --upgrade certbot certbot-nginx certbot-dns-cloudflareSetting in up#
挑戰成功憑證會被放在 /etc/letsencrypt/live/domain 資料夾內。
Operate#
手動更新憑證
$ sudo certbot renew -qReference#
Official docs: