How-To-Secure-A-Linux-Server
튜토리얼imthenachoman/How-To-Secure-A-Linux-Server
지속적으로 업데이트되는 Linux 서버 보안 강화 가이드
개요
이 가이드는 Linux 서버 보안 강화를 위한 단계별 설명을 제공하며, SSH 보안, 방화벽 구성, 침입 탐지 등을 다룹니다. 내용은 커뮤니티에서 기여되었으며 지속적으로 업데이트됩니다.
README 미리보기
# How To Secure A Linux Server\n\nAn evolving how-to guide for securing a Linux server that, hopefully, also teaches you a little about security and why it matters.\n\n[](#license)\n\n## Table of Contents\n\n- [Introduction](#introduction)\n - [Guide Objective](#guide-objective)\n - [Why Secure Your Server](#why-secure-your-server)\n - [Why Yet Another Guide](#why-yet-another-guide)\n - [Other Guides](#other-guides)\n - [To Do / To Add](#to-do--to-add)\n- [Guide Overview](#guide-overview)\n - [About This Guide](#about-this-guide)\n - [My Use-Case](#my-use-case)\n - [Editing Configuration Files - For The Lazy](#editing-configuration-files---for-the-lazy)\n - [Contributing](#contributing)\n- [Before You Start](#before-you-start)\n - [Identify Your Principles](#identify-your-principles)\n - [Picking A Linux Distribution](#picking-a-linux-distribution)\n - [Installing Linux](#installing-linux)\n - [Pre/Post Installation Requirements](#prepost-installation-requirements)\n - [Other Important Notes](#other-important-notes)\n - [Using Ansible Playbooks to secure your Linux Server](#using-ansible-playbooks-to-secure-your-linux-server)\n- [The SSH Server](#the-ssh-server)\n - [Important Note Before You Make SSH Changes](#important-note-before-you-make-ssh-changes)\n - [SSH Public/Private Keys](#ssh-publicprivate-keys)\n - [Create SSH Group For AllowGroups](#create-ssh-group-for-allowgroups)\n - [Secure `/etc/ssh/sshd_config`](#secure-etcsshsshd_config)\n - [Remove Short Diffie-Hellman Keys](#remove-short-diffie-hellman-keys)\n - [2FA/MFA for SSH](#2famfa-for-ssh)\n- [The Basics](#the-basics)\n - [Limit Who Can Use sudo](#limit-who-can-use-sudo)\n - [Limit Who Can Use su](#limit-who-can-use-su)\n - [Run applications in a sandbox with FireJail](#run-applications-in-a-sandbox-with-firejail)\n - [NTP Client](#ntp-client)\n - [Securing /proc](#securing-proc)\n - [Force Accounts To Use Secure Passwords](#force-accounts-to-use-secure-passwords)\n - [Autom
FAQ (4)
설정SSH 클라이언트 구성에서 'HashKnownHosts yes'를 활성화해야 하나요?
네, /etc/ssh/ssh_config 또는 ~/.ssh/config에서 'HashKnownHosts yes'를 설정하면 known_hosts 파일의 호스트 이름과 주소가 해시됩니다. 이렇게 하면 파일이 유출되어도 서버 신원이 평문으로 노출되지 않아 SSH 웜 공격과 우연한 도청을 완화할 수 있습니다. 관련 설정 파일에 'HashKnownHosts yes' 줄을 추가한 후 SSH 연결을 다시 시작하십시오.
문제 해결모바일 인터넷 연결(LTE)을 사용할 때 SSH 연결 끊김을 방지하는 방법?
TCPKeepAlive(스푸핑 가능한 보안 위험)를 비활성화하고 대신 ClientAliveInterval과 ClientAliveCountMax를 사용하십시오. NAT 타임아웃이 25초까지 낮은 LTE 네트워크의 경우 /etc/ssh/sshd_config에서 ClientAliveInterval 25와 ClientAliveCountMax 3을 설정하십시오. SSH를 재시작하십시오: sudo systemctl restart sshd. 이는 25초마다 암호화된 keep-alive를 전송하고, 연결을 끊기 전 최대 3번의 응답 누락을 허용합니다.
문제 해결낮은 엔트로피로 인한 헤드리스 Linux 서버에서 예측 가능한 SSH 키를 수정하는 방법은?
rng-tools를 설치하여 엔트로피 소스를 추가하십시오. Debian/Ubuntu에서: sudo apt-get install rng-tools. 하드웨어 엔트로피의 경우 Infinite Noise TRNG를 고려하세요. 자세한 내용은 https://hackaday.com/2017/11/02/what-is-entropy-and-how-do-i-get-more-of-it/ 및 https://www.2uo.de/myths-about-urandom을 참조하십시오
문제 해결SSH의 default port를 변경하면 어떻게 brute-force attack 시도를 줄일 수 있나요?
SSH 포트를 22에서 랜덤한 높은 포트(예: 6222)로 변경하고 /etc/ssh/sshd_config에 (Port 6222)를 설정한 후, UFW에서 이를 허용합니다: sudo ufw allow 6222/tcp. SSH를 재시작합니다: sudo systemctl restart sshd. 이렇게 하면 자동화된 무차별 대입 공격 시도가 분당 수백 건에서 몇 건으로 줄어듭니다. 완전히 제거하려면 비밀번호 인증 비활성화(PasswordAuthentication no)와 SSH 키 사용을 함께 적용하세요. 포트 노킹(예: knockd)은 포트를 완전히 숨깁니다.