기계적 인조 인간

데비안 9에서 암호화하자

Foreigner - I Want To Know What Love Is (Official Music Video)

Foreigner - I Want To Know What Love Is (Official Music Video)

차례:

Anonim

Let 's Encrypt는 ISRG (Internet Security Research Group)에서 만든 인증 기관입니다. 수동 인증서 생성, 검증, 설치 및 갱신을 제거하도록 설계된 완전 자동화 된 프로세스를 통해 무료 SSL 인증서를 제공합니다.

Let 's Encrypt에서 발급 한 인증서는 발급일로부터 90 일 동안 유효하며 오늘날 모든 주요 브라우저에서 신뢰합니다.

이 튜토리얼은 데비안 9의 certbot 도구를 사용하여 무료 Let 's Encrypt를 얻는 과정을 안내합니다. 또한 새 SSL 인증서를 사용하고 HTTP / 2를 활성화하도록 Apache를 구성하는 방법도 보여줍니다.

전제 조건

이 학습을 계속하기 전에 다음 전제 조건을 충족하는지 확인하십시오.

  • sudo 권한이있는 사용자로 로그인했습니다. 서버 공용 서버 IP를 가리키는 도메인 이름이 있습니다. example.com .Apache가 설치되어 사용합니다. 도메인의 아파치 가상 호스트. 작성 방법에 대한 자세한 내용은이 지시 사항을 따르십시오.

Certbot 설치

Certbot은 SSL 인증서를 획득하고 갱신하기위한 작업을 자동화 할 수있는 모든 기능을 갖춘 사용하기 쉬운 도구입니다. certbot 패키지는 기본 데비안 리포지토리에 포함되어 있습니다.

패키지 목록을 업데이트하고 다음 명령을 사용하여 certbot 패키지를 설치하십시오.

sudo apt update sudo apt install certbot

Strong Dh (Diffie-Hellman) 그룹 생성

Diffie-Hellman 키 교환 (DH)은 보안되지 않은 통신 채널을 통해 암호화 키를 안전하게 교환하는 방법입니다.

2048 비트 DH 매개 변수의 새로운 세트를 생성하려면 다음을 실행하십시오.

sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 원하는 경우 크기를 최대 4096 비트로 변경할 수 있지만이 경우 시스템 엔트로피에 따라 생성 시간이 30 분 이상 걸릴 수 있습니다.

Let 's Encrypt SSL 인증서 얻기

도메인에 대한 SSL 인증서를 얻기 위해 ${webroot-path}/.well-known/acme-challenge 디렉토리에서 요청 된 도메인의 유효성을 검증하기위한 임시 파일을 작성하여 작동하는 Webroot 플러그인을 사용합니다. Let 's Encrypt 서버는 요청 된 도메인이 certbot이 실행되는 서버로 확인되는지 확인하기 위해 임시 파일에 HTTP 요청을 보냅니다.

더 간단하게하기 위해 .well-known/acme-challenge 에 대한 모든 HTTP 요청을 단일 디렉토리 /var/lib/letsencrypt 합니다.

다음 명령은 디렉토리를 작성하고 Apache 서버에 쓸 수 있도록합니다.

sudo mkdir -p /var/lib/letsencrypt/.well-known sudo chgrp www-data /var/lib/letsencrypt sudo chmod g+s /var/lib/letsencrypt

코드 중복을 피하려면 다음 두 가지 구성 스 니펫을 작성하십시오.

/etc/apache2/conf-available/letsencrypt.conf

Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" AllowOverride None Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS Alias /.well-known/acme-challenge/ "/var/lib/letsencrypt/.well-known/acme-challenge/" AllowOverride None Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS /etc/apache2/conf-available/ssl-params.conf

SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLHonorCipherOrder On Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" Header always set X-Frame-Options DENY Header always set X-Content-Type-Options nosniff # Requires Apache >= 2.4 SSLCompression off SSLUseStapling on SSLStaplingCache "shmcb:logs/stapling-cache(150000)" # Requires Apache >= 2.4.11 SSLSessionTickets Off SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem"

위의 코드 조각은 Cipherli.st에서 권장하는 칩퍼를 사용하고 있으며 HSTS (HTTP Strict Transport Security) 인 OCSP Stapling을 활성화하고 보안 중심 HTTP 헤더를 거의 적용하지 않습니다.

구성 파일을 활성화하기 전에 다음을 실행하여 mod_ssl mod_headers 모두 활성화하십시오.

sudo a2enmod ssl sudo a2enmod headers

HTTP / 2 모듈을 활성화하면 사이트가 더 빠르고 강력 해집니다.

sudo a2enmod

다음 명령을 실행하여 SSL 구성 파일을 사용하십시오.

sudo a2enconf letsencrypt sudo a2enconf ssl-params

변경 사항을 적용하려면 Apache 구성을 다시로드하십시오.

sudo systemctl reload apache2

SSL 인증서 파일을 얻으려면 웹 루트 플러그인과 함께 Certbot 도구를 사용하십시오.

sudo certbot certonly --agree-tos --email [email protected] --webroot -w /var/lib/letsencrypt/ -d example.com -d www.example.com

SSL 인증서가 성공적으로 획득되면 certbot은 다음 메시지를 인쇄합니다.

IMPORTANT NOTES: IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will expire on 2019-01-17. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you lose your account credentials, you can recover through e-mails sent to [email protected]. - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF:

인증서 파일이 준비되었으므로 다음과 같이 도메인 가상 호스트 구성을 편집하십시오.

/etc/apache2/sites-available/example.com.conf

ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration ServerName example.com ServerAlias www.example.com Redirect permanent / https://example.com/ ServerName example.com ServerAlias www.example.com Protocols h2 http:/1.1 Redirect permanent / https://example.com/ DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem # Other Apache Configuration

위 구성으로 HTTPS를 강제 실행하고 www를 www가 아닌 ​​버전으로 리디렉션합니다. 필요에 따라 구성을 자유롭게 조정하십시오.

변경 사항을 적용하려면 Apache 서비스를 다시로드하십시오.

sudo systemctl reload apache2

https:// 사용하여 웹 사이트를 열면 녹색 자물쇠 아이콘이 나타납니다.

자동 갱신 SSL 인증서 암호화

암호화하자 인증서는 90 일 동안 유효합니다. 인증서가 만료되기 전에 자동으로 갱신하기 위해 certbot 패키지는 하루에 두 번 실행되는 cronjob을 생성하고 만료 30 일 전에 인증서를 자동으로 갱신합니다.

인증서가 갱신되면 Apache 서비스도 다시로드해야합니다. --renew-hook "systemctl reload apache2" /etc/cron.d/certbot 파일에 추가하여 다음과 같이 표시하십시오.

/etc/cron.d/certbot

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew --renew-hook "systemctl reload apache2"

갱신 프로세스를 테스트하려면 certbot --dry-run 스위치를 사용하십시오.

sudo certbot renew --dry-run

오류가 없으면 갱신 프로세스가 완료되었음을 의미합니다.

결론

이 학습서에서는 Let 's Encrypt client certbot을 사용하여 도메인에 대한 SSL 인증서를 얻었습니다. 또한 코드 중복을 피하기 위해 Apache 스 니펫을 작성하고 Apache가 인증서를 사용하도록 구성했습니다. 학습서 끝에서 자동 인증서 갱신을위한 cronjob을 설정했습니다.

아파치 데비안 certbot ssl을 암호화하자

이 글은 데비안 9 시리즈에 LAMP Stack을 설치하는 방법의 일부입니다.

이 시리즈의 다른 게시물:

• 데비안 9에 아파치를 설치하는 방법 • 데비안 9에 PHP를 설치하는 방법 • 데비안 9에 아파치 가상 호스트를 설정하는 방법 • 데비안 9에 MariaDB를 설치하는 방법 • 데비안 9에서 암호화하자 보안 아파치