[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] userdel 명령어: 사용자 계정 삭제 명령어

    리눅스에서 useradd로 계정 생성 후 삭제가 필요한 경우 userdel 명령어를 사용합니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기✅ userdel 명령어 기본 사용은 아래와 같습니다. ✅ userdel 주로 사용하는 옵션 userlde만 입력해서 사용자를 삭제할 경우 보통 /home/[user]로 계정명이 폴더에 버전에 따라…

  • 리눅스 톰캣 설치

    리눅스 톰캣 설치(Ver 9.0.83)를 진행해 보겠습니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기1. wget 설치 먼저 레드헷 계열에서 사용하는 패키지 매니저인 yum으로 wget 설치를 진행합니다. wget은 웹 서버로부터 컨텐츠를 가져오는 프로그램입니다. 2. 리눅스 톰캣 설치하기: Apach Tomcat ▼ Apach Tomcat…

  • Linux: 아파치 재시작/시작/중지 명령어[CentOS 7]

    리눅스 웹서버를 운영하다 보면 CentOS에서 아파치 재시작을 하는 경우가 많습니다. 재시작 및 시작, 중지 명령어에 대해 알아 보겠습니다. 아파치는 HTTP 아파치 서버로 불리는 HTTP 웹서버입니다. 쉬운 웹서버 구축과 기능적인 측면에서 우수하기 때문에 많은 중소기업 및 대형사이트에서 사용합니다. 목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf…

  • 리눅스 YUM 개념과 기본 명령어

    YUM(Yellow dog Updater, Modified)은 레드햇(RPM) 계열 리눅스 배포판에서 사용되는 패키지 설치 및 관리 도구입니다. 기존의 RPM 방식은 패키지 설치 시 의존성 문제로 사용자가 필요한 도구를 일일이 설치해야 하는 번거로움이 있었습니다. YUM은 이러한 의존성 문제를 자동으로 해결해 주며, 필요한 패키지와 관련된 의존 패키지를 함께 설치하여 오류를 최소화합니다. 의존성이 존재할 때 관련된 다른 패키지들을 자동으로…

  • Linux란? 리눅스의 특징 및 리눅스의 종류

    목차✅ Certbot 설치: snap 설치✅ Let’s Encrypt 보안인증서 설치🔲 자동 갱신 테스트 하기✅ httpd.conf or virtual.conf 설정: 포트 접근 허용하기■ ‘Linux’란? -simple ‘Linux’ 는 유닉스의 무료 버전(오픈소스)으로 이해하면 된다.  유닉스는1969년 벨 연구소에서 만들어졌습니다.  리눅스는 1991년 8월 리누스 토르발스가 어셈블리어로 리눅스 커널(kernel) 0.01 버전을 만들면서 시작되었습니다. 1992년에 0.02 버전이 만들어지면서 인터넷에 소스 코드를 공개한…

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

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

답글 남기기

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

Prove your humanity: 9   +   8   =