[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

  • 리눅스 cd 명령어

    cd 명령어는 “Change Directory”의 약자로, 현재 작업 디렉토리(현재 위치)를 다른 디렉토리로 이동할 때 사용하는 명령어입니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기✅ cd 명령어 기본 사용 방법 ✅ 사용 예시 cd 명령은 절대 경로(/부터 시작)를 기입해서 이동하는 방식과 상대 경로(….

  • 셔뱅(Shebang) [#! /bin/bash]

    shebang (셔뱅 또는 해시뱅)은 스크립트 파일의 첫 줄에 쓰이는 #!(해시 기호 + 느낌표)로 시작하는 구문입니다. 이 줄은 해당 스크립트를 어떤 인터프리터로 실행 할지를 지정합니다. 인터프리터(interpreter)는 프로그래밍 언어로 작성된 코드를 한 줄씩 읽고 즉시 실행하는 프로그램입니다. 이는 “작성된 명령을 번역해서 곧바로 실행해주는 번역기”라고 볼 수 있습니다. 보통 ASCII 텍스트 파일로 작성된 셸 스크립트에서 해시…

  • 리눅스 tee 명령어

    리눅스 tee 명령어는 배관시설에 비유해서 이름이 붙여진 명령어입니다. 파이프 모양과 똑같은 “T”에서 본따 tee 명령어이며 표준 출력으로 하나 이상의 다른 파일을 동시에 출력합니다. tee 명령어의 목적은 작업 진행 중 파이프라인(I)의 중간 내용을 알고 싶을 때 유용하게 사용할 수 있습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf…

  • cp 명령어 옵션 및 실행 시 일괄 덮어쓰기 설정 | yes, \(역슬래쉬) 2가지 설정

    cp 명령어는 Copy의 약자로 파일 및 디렉토리를 복사합니다. 기본 사용법은 간단하게 복사할 대상과 새로운 이름 등을 설정하여 사용할 수 있습니다. cp 명령어를 실행할 때 같은 이름의 대상 파일이 있을 때는 사용자에게 묻지 않고 덮어쓰기가 되는데, 이를 방지하기 위해 alias “cp=’cp -i”로 설정되어 있습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동…

  • 리눅스 mkdir 명령어 | Linux 디렉토리 생성하기

    리눅스 mkdir 명령어는 Make Directory의 약자로 리눅스에서 디렉토리(폴더)를 생성하는 명령어입니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기✅ 리눅스 mkdir 명령어 기본 사용법 경로 미 지정 시 현재 위치에서 디렉토리가 생성됩니다. mkdir 명령어 옵션 설명 -m 디렉토리 생성 시 권한(퍼미션) 설정(기본…

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

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

답글 남기기

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

Prove your humanity: 4   +   5   =