[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

  • nslookup 명령어

    nslookup 명령어는 네임 서버 조회(Name Server Lookup)를 뜻하는 명령어로 네임 서버의 정보를 얻기 위한 명령어입니다. DNS(Domain Name System)에 질의 후 대상 도메인의 IP 주소나 DNS 레코드 등의 정보를 얻기 위한 네트워크 명령어입니다. DNS 서버의 정상적인 작동을 통해 정상적인 네트워크 설정이 되었는지 확인할 때 많이 사용하게 되는 명령어 중 하나입니다. 보통 맥 OS 및…

  • 리눅스 which whereis locate: 3가지 위치(경로) 확인 명령어

    리눅스 which와 whereis 명령어 명령어의 위치를 알 수 있는 명령어는 find 명령어를 이용해서 파일을 찾을 수 있지만 find 명령어는 시간이 소요되는 단점도 존재합니다. locate 명령어는 파일명을 빠르게 검색할 때 사용할 수 있습니다. 리눅스 기본 명령어 3가지에 대해 알아 보겠습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf…

  • [Ubuntu] apt 명령어 | apt-get 명령어 사용법과 차이점

    Red Hat 계열 리눅스에서는 패키지 관리를 위해 dnf 명령어를 사용하며, Debian 계열에서는 apt 명령어를 사용합니다. Ubuntu와 같은 Debian 기반 배포판에서는 두 명령어가 모두 사용 가능하지만, 목적과 사용 방식에 따라 약간의 차이가 있습니다. 이 글에서는 apt와 apt-get의 차이를 간단히 비교하고, apt 명령어에서 자주 사용하는 명령어 예제를 함께 정리해보겠습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s…

  • rm 명령어

    목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기1. rm 명령어 ‘rm 명령어‘ 는 파일 및 디렉토리를 삭제하는 명령어이다. ‘rm 명령어’ 는 심볼릭 링크는 삭제하지만 링크의 대상 파일은 삭제하지 않는다. ls 명령어와 함께 많이 사용되는 명령어이다. rm(remove) 명령어 rm –remove 파일 및…

  • [Ubuntu] 우분투 설치(22.04.5) | 우분투 root 초기 비밀번호 생성

    오라클의 VitualBox로 우분투 설치를 진행해 보겠습니다. 먼저 IOS 파일을 다운로드 받기 위해 구글에서 [우분투 서버 다운로드]를 검색해서 설치하고자 하는 우분투 버전을 확인 후 다운로드를 진행합니다. 저의 경우는 22.04.5 버전을 설치하기로 했기에 예전 버전을 찾은 후 진행하였습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정:…

  • 리눅스 wget 명령어

    wget 명령어는 웹의 다운로드 링크를 리눅스 커멘드라인에서 실행해 다운로드를 할 수 있는 명령어입니다. HTTP, HTTPS, FTP 프로토콜을 이용해서 웹 서버에서 다운로드가 가능합니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기wget 설치하기 레드헷 계열에서 사용하는 패키지 매니저인 yum으로 wget 설치를 진행합니다. 기본…

답글 남기기

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

Prove your humanity: 3   +   5   =