[Linux] Certbot 설치 및 갱신 설정: Let’s Encrypt 인증서

웹사이트에서 HTTPS를 활성화하려면 인증 기관(CA)에서 인증서를 설치해야 합니다. Let’s Encrypt는 2억 2500 만 개의 사이트에 TLS 인증서를 제공하는 비영리 인증 기관(CA)으로 제공하는 Certbot 설치를 통해 무료로 인증서를 발급받을 수 있습니다. CentOS, Ubuntu, Rocky Linux 등 Shell을 이용할 수 있는 사용자는 Certbot ACME 클라이언트를 사용하는 것을 권장하고 있습니다.

✅ Certbot 설치: snap 설치

2021년 이전에는 yum 설치 후 자동 갱신 시 ./letsencrypt-auto 형식의 명령으로 도메인을 자동 갱신했습니다.

cerobot-auto의 지원이 중단되면서 “시스템이 더 이상 certbot-auto에서 지원되지 않습니다. Certbot은 더 이상 업데이트를 받지 않습니다.”와 같은 메시지를 확인한 경우가 있을 수 있습니다.

TLS/SSL 인증서 설치를 위한 Certbot 설치 시 권장 사항은 snap을 이용해서 설치하는 것을 권장합니다.

snap이 서버에 설치되었다면 snap으로 설치를 진행합니다.

~]# snap install --classic certbot
2024-07-19T10:09:48Z INFO Waiting for automatic snapd restart...
certbot 2.11.0 from Certbot Project (certbot-eff✓) installed

certbot명령이 실행될 수 있는지 심볼릭 링크 명령어를 실행합니다.

~]# ln -s /snap/bin/certbot /usr/bin/certbot
~]# ll /usr/bin/certbot
lrwxrwxrwx 1 root root 17 Jul 19 10:12 /usr/bin/certbot -> /snap/bin/certbot

✅ Let’s Encrypt 보안인증서 설치

~]# certbot certonly --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 사용할 이메일 주소 입력

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf. You must agree in
order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:y < 동의하기
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o:y < 동의하기
Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mydomain.com
2: www.mydomain.com.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):1 < 루트 도메인으로 설치
Requesting a certificate for ukcresearch.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/mydomain.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/mydomain.com/privkey.pem
This certificate expires on 2024-10-21.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

마지막으로 인증서가 백그라운드에서 자동 갱신 되도록 설정되었다는 내용을 확인할 수 있습니다.

🔲 자동 갱신 테스트 하기

]# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/ukcresearch.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for ukcresearch.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
  /etc/letsencrypt/live/mydomain.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

자동 갱신 테스트를 통해 자동 갱신 역시 정상적으로 되는 것을 확인합니다.

certbot을 갱신하는 명령은 다음 위치 중 하나에 설치됩니다.

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers

✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기

<VirtualHost *:443> # 기존 80번 포트를 443 포트로 변경해 주기 #
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /home/mydomain/www

   <Directory /home/호스트ID/www>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
  </Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/archive/mydomain.com/cert1.pem
SSLCertificateKeyFile /etc/letsencrypt/archive/mydomain.com/privkey1.pem
SSLCertificateChainFile /etc/letsencrypt/archive/mydomain.com/chain1.pem
SSLCACertificateFile /etc/letsencrypt/archive/mydomain.com/fullchain1.pem
</VirtualHost>
HTTPS SSL 보안인증서 적용 미적용 차이

Similar Posts

  • [Linux] mod_ssl.so Apache 모듈 설치하기

    아파치를 사용하는 리눅스 서버에 SSL을 적용하려고 할 때 아피치 모듈 중 mod_ssl.so가 설치되어 있어야 합니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기✅ mod_ssl.so 설치 ✅ 서버 방화벽 포트 443 열어두기 SSL 포트인 443 포트가 방화벽에서 열려있는 상태로 활성화 되어 있어야…

  • [Linux] Shell 확장 6가지와 Shell 인용 3가지

    echo 명령어를 사용해서 Shell 확장(Expansion)에 대해 알아 보겠습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기 1. Shell 확장 Shell 확장(Expansion)이란 셸에서 프로그램을 실행하기 직전 사용자가 입력한 인자를 정해진 의미에 맞게 해석해서 입력 or 출력으로 전환하는 것을 의미합니다. 프로그램은 echo를 포함한…

  • 로그 파일 삭제 쉘 스크립트 만들기(날짜 20xx, 용량)

    httpd.conf 파일에 access_log 및 error_log를 설정 했을 때 logrotate 설정이 아닌 경우 로그 파일 삭제 쉘 스크립트가 필요할 때가 있습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기✅ 로그 파일 삭제 쉘 스크립트 ✅ crontab 설정하기 크론탭 설정을 진행 해 줍니다. 리눅스…

  • [Linux] 쉘(Shell)과 커널&쉘 스크립트 및 프롬프트

    리눅스에 대해 공부하면서 터미널 창에서 명령어를 입력해서 관리를 하지만 시스템 자체에 대한 공부가 리눅스 서버를 운영하는데 많은 도움이 되기 때문에 기초와 개념에 대해 알아야 할 필요성을 가지게 되었습니다. 리눅스 쉘(Shell)과 쉘 스크립트(Shell Script) 그리고 프롬프트(Prompt)의 기본 개념에 대해 알아 보겠습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅…

  • SSL 보안인증서 설치(CentOS 7)

    SSL 보안인증서는 한국·해외 웹사이트에서 필수 요소 중 하나입니다. SSL 보안인증서 설치 후 운영이 필요한 이유는 광고가 아닌 유기적 트래픽을 원할 경우 SSL(TLS) 인증서는 검색엔진최적화(SEO)에 필수 항목 중 하나이기 때문입니다. SSL 보안인증서는 사용자와 서버의 통신이 암호화되어 중간에 해커가 데이터를 가로채지 못하도록 하는 방화벽입니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신…

  • HTTP 상태 코드 표 [100~500] 정리

    HTTP 상태 코드는 운영 중인 서버의 오류를 확인하는 데 매우 중요한 지표로 활용됩니다. HTTP(Hypertext Transfer Protocol)란 웹 서버와 웹 클라이언트 사이에 데이터를 주고 받기 위해 사용되는 프로토콜 중 하나이며, TCP/IP 프로토콜 위에서 동작합니다. HTTP는 HTML, XML과 같은 하이퍼텍스트(Hypertext)만 전송하는 것이 아닌 이미지, 동영상, JavaScript 등의 다양한 파일을 데이터로 전송할 수 있습니다. 목차✅ Certbot…

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Prove your humanity: 9   +   3   =