KodeKloud Days 5-8: SELinux 및 Cron Jobs

발행: (2025년 12월 24일 오전 04:00 GMT+9)
5 분 소요
원문: Dev.to

Source: Dev.to

(번역할 텍스트를 제공해 주시면 한국어로 번역해 드리겠습니다.)

Day 5: SELinux 구성 – “잠깐, 이거 Ubuntu가 아니네?”

My confident first attempt:

sudo apt update
sudo apt install -y selinux-basics

Result: Command not found.
Turns out I was on CentOS Stream, not Ubuntu. Different package manager, different everything.

Check your OS first (lesson learned)

cat /etc/os-release

CentOS uses dnf, not apt:

sudo dnf install -y selinux-policy selinux-policy-targeted

Edit the SELinux config:

sudo vi /etc/selinux/config
# Change SELINUX=enforcing to SELINUX=disabled

Why this surprised me: Every DevOps tutorial I’d done uses Ubuntu (AWS, Docker, Kubernetes). Encountering CentOS felt like showing up to a JavaScript class and being handed Assembly code.
Lesson: Always check /etc/os-release before assuming the distro. Package managers are not interchangeable.

Day 6: Cron 작업 – 예상보다 쉬움

5분마다 /tmp/cron_text에 “hello”를 출력하는 cron 작업을 설정합니다.

# Install cron daemon
sudo dnf install -y cronie
sudo systemctl enable --now crond

# Add the job (as root)
sudo su -
echo "*/5 * * * * echo hello > /tmp/cron_text" >> /var/spool/cron/root

# Verify
crontab -l

*/5 * * * * 의 Cron 구문 설명

위치의미
1 (*/5)5분마다
2 (*)매시간
3 (*)매월 일
4 (*)매월
5 (*)요일마다

번역: “우주 열사망이 일어날 때까지 5분마다 이 작업을 실행합니다.”

Day 7: 비밀번호 없는 SSH – 공개 키의 마법

점프 호스트에서 모든 애플리케이션 서버로 비밀번호 없는 SSH를 설정합니다.

# Generate SSH key pair
ssh-keygen -t rsa -b 4096

# Copy to servers (the easy way)
ssh-copy-id tony@stapp01
ssh-copy-id steve@stapp02
ssh-copy-id banner@stapp03

# Test it
ssh tony@stapp01 hostname   # No password prompt = success

중요한 권한

PathMode
~/.ssh/700 (drwx------)
~/.ssh/authorized_keys600 (-rw-------)
~/.ssh/id_rsa600 (-rw-------)
~/.ssh/id_rsa.pub644 (-rw-r--r--)

잘못된 권한 설정은 SSH가 키를 조용히 무시하게 합니다.

Day 8: Ansible 설치 – 버전 지옥

특정 Ansible 버전을 전역에 설치합니다.

# Wrong: user‑only installation
python3 -m pip install --user ansible

# Right: global installation
sudo python3 -m pip install "ansible==4.8.0"

# Verify
ansible --version
which ansible   # Should show /usr/local/bin/ansible

차이점

  • --user~/.local/bin에 설치됩니다 (현재 사용자만 사용)
  • sudo pip install/usr/local/bin에 설치됩니다 (모든 사용자 사용)

버전 지정자는 항상 따옴표로 감싸세요: "ansible==4.8.0"; 그렇지 않으면 셸 확장으로 명령이 깨질 수 있습니다.

2주 차 통계

  • 시도한 패키지 관리자: 2개 (apt는 실패, dnf는 성공)
  • 생성한 크론 작업: 3개 (서버당 하나씩)
  • 생성한 SSH 키 쌍: 1개 (4096비트 RSA)
  • Ansible 설치: 2번 (사용자 수준, 그 다음 전역)
  • “Ubuntu가 아님” 깨달음: 1번 (CentOS 서프라이즈)
  • CentOS에서 apt를 입력한 횟수: 약 5번 (근육 기억이 고집스러움)

주요 내용

이제 암기한 명령어

cat /etc/os-release          # Always check your distro
crontab -l                    # List cron jobs
ssh user@host hostname        # Test passwordless SSH
ansible --version             # Verify Ansible installation

나에게 교훈이 된 실수들

  • 명령어를 실행하기 전에 항상 OS를 확인하세요.
  • SSH 권한은 정확히 설정되어야 합니다.
  • 전역 설치와 사용자 설치는 차이가 있습니다.
  • 버전 관리가 선택 사항이 아닙니다.

다음 단계

  • 9‑12일 차: Ansible 플레이북 (드디어 설치한 것 사용)
  • Docker 기본
  • 네트워크 구성
  • 더 많은 트러블슈팅 (아마도)

전체 기사: 자세한 내용, 모든 명령어, UI 고민 전체 이야기는 원본 게시물을 확인하세요 👉 전체 기사 읽기

Back to Blog

관련 글

더 보기 »