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

공정위 광고 문구 Ver 2.0

웹사이트에서 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

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

    리눅스 mkdir 명령어는 Make Directory의 약자로 리눅스에서 디렉토리(폴더)를 생성하는 명령어입니다. ✅ 리눅스 mkdir 명령어 기본 사용법 경로 미 지정 시 현재 위치에서 디렉토리가 생성됩니다. mkdir 명령어 옵션 설명 -m 디렉토리 생성 시 권한(퍼미션) 설정(기본 값: 755) -v 디렉토리 생성 후 생성된 디렉토리에 대한 메시지 출력 -p 디렉토리의 하위 디렉토리 생성 ✅ mkdir 명령어…

  • 리눅스 who, w 명령어 & user 명령어

    리눅스 who 명령어는 현재 서버에 로그인한 사용자 리스트를 보여주는 명령어입니다. w 명령어는 현재 시스템에 로그인한 사용자와 사용자의 작업 내용을 보여주는 명령어로 각각의 차이가 있습니다. ✅ 리눅스 who 명령어 현재 접속 사용자(USER) 터미널 유형(TTY) 접속 시간 및 IP rocky pts/0, pts/1 .. 2070-02-09 10:15 (xxx.xx.xx8.254) ✅ 리눅스 w 명령어 w 명령어 확인 정보 설명…

  • clear 명령어

    ■ clear 명령어 – 기타명령어 clear 명령어는 리눅스에서 출력 된 터미널 화면을 지우는 명령어이다. clear 명령어는 도스의 cls 명령어와 동일한 뜻과 기능을 가지고 있다. 리눅스 터미널 화면을 지워주고 커서는 화면 상단에 위치학게 된다. 아래처럼 ll 명령어를 입력 후 clear 명령어를 입력해서 테스트 해 볼 수 있다.

  • [Linux] CentOS 7 설치 | VirtualBox 설치

    VirtualBox에 CentOS 7 설치를 진행 해 보겠습니다. 미리 다운로드 받은 ISO 파일로 이미 설정을 완료한 상태입니다. ✅ CentOS 7 설치 진행 Install CentOS를 선택하고 다음 단계로 넘어갑니다. 언어 선택 화면에서 한국어를 선택합니다. 🔲 KDUMP 설정 KDUMP를 클릭하여, 체크 된 활성화를 비 활성화로 변경합니다. KDUMP 설정은 테스트 용도이거나, 커널 패닉의 주요 원인이 하드웨어(드라이버, 디바이스…

  • 리눅스 커널(Kernel)이란? | 커널 버전

    리눅스 커널과 커널은 같은 뜻을 가지고 있습니다. 커널을 말할 때 리눅스 커널을 이야기 하는 것입니다. 핵심(&알맹이)이라는 뜻을 가진 커널(Kernel)은 내부 계층에 속하며, Shell 명령과 하드웨어를 연결해 주는 역할을 합니다. 리눅스 커널(Kernel)의 개념 컴퓨터는 크게 물리적으로 만질 수 있는 하드웨어(키보드, 모니터, 본체:CPU, 메모리 등)와 소프트웨어로 나뉘게 됩니다. 소프트웨어는 운영체제인 윈도우, 리눅스, MacOS 등이며, 추가로…

  • ps 명령어(프로세스 명령어)

    ps 명령어는 현재 실행 중인 프로세스를 출력하는 명령어입니다. 1. ps 명령어 옵션 ps에서 주로 사용되는 명령어입니다. 기본 사용 옵션은 아래와 같습니다. 2. ps -ef 명령어 ps -ef 명령어는 모든 프로세스를 포멧 리스트로 출력해 줍니다. 2.1 출력 필드 ps 출력 필드 기본 설명입니다. 3. ps -aux 사용 3.1 ps -aux의 필드 4. 프로세스 상태…

답글 남기기

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

Prove your humanity: 5   +   1   =