首先要依照官網進行certbot安裝
certbot需要透過snap安裝,目前Ubuntu應該預設都有安裝。所以這邊直接跳到安裝Certbot:
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo snap set certbot trust-plugin-with-root=ok
跟root掛完後,如果跟我一樣懶,是可以選擇使用外掛,或是參考別人的文章進行ACME挑戰。這邊紀錄使用cloudflare讓certbot自動幫我進行ACME挑戰:
sudo snap install certbot-dns-cloudflare
==========================================================
以上進行完畢後,就需要開始把Cloudflare上面的API key寫出來。這邊會需要製作一個.ini檔,讓certbot吃。假設該檔名為certbot.ini,內容應該如下:
# Cloudflare API credentials used by Certbot dns_cloudflare_email = cloudflare@example.com dns_cloudflare_api_key = 0123456789abcdef0123456789abcdef01234
其中dns_cloudflare_email就是在clouflare上面的帳號,底下api key可以到 https://dash.cloudflare.com/profile/api-tokens 這網頁底下,找出Global API key,在把內容貼上即可。但因為這邊的帳號密碼還有api key有點敏感,所以建議認證完畢後就把ini砍掉。
接著進行Cerbot認證,letsencrypt支援wildcard網域認證:
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ./certbot.ini -d *.markliou.tw
認證完畢後,就可以在 /etc/letsencrypt/live/markliou.tw底下找到認證檔。
基本上會用到的就兩個:
- privkey.pem : 這就是privary key
- fullchain.pem: 這是public key。因為letsencrypt會連同上面的一些server一起認證,所以內容會比較多。
把以上幾個key放到正確位置後就能開始運作。
Rerefernce:
- https://certbot.eff.org/instructions?ws=other&os=ubuntufocal
- https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials
- https://blog.miniasp.com/post/2021/02/11/Create-SSL-TLS-certificates-from-LetsEncrypt-using-Certbot
沒有留言:
張貼留言