Linux/Security 6

CentOS 7 포트를 사용하는 데몬(프로세스)명 확인하기

예를 들어 서버에서 631포트가 LISTEN 상태로 되어 있고, 어떤 데몬(프로세스)가 사용하고 있는지 확인 netstat 명령어로 포트와 사용하는 프로세스 확인 # netstat -tnlp | egrep ':631' tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1382/cupsd tcp6 0 0 ::1:631 :::* LISTEN 1382/cupsd - cupsd : Common UNIX Printing System (프린터 서버) pstree 명령어로 프로세스 상관관계 확인 (pstree가 설치되어 있지 않으면, yum -y install psmisc으로 설치) # pstree systemd─┬─ModemManager───2*[{ModemManager}] ├─NetworkMa..

Linux/Security 2019.12.11

[Linux-Security] CentOS 7 sftp logging and monitoring. (sftp 로깅 설정과 모니터링)

1. /etc/ssh/sshd_config 파일에 146번 라인에 sftp 로깅설정 추가 (빨간색) Subsystem sftp /usr/libexec/openssh/sftp-server -f local2 -l INFO 2. /etc/rsyslog.conf 로깅 파일 설정 원격 로그서버로 발송하려하면 로그서버를 지정한다. 원격 로그서버에 적재되면 통합으로 모니터링이 가능하겠다. 3. 로그관리 - /etc/logrotate.d/syslog 파일에 /var/log/sftp.log 추가. (로컬에 쌓을 때, 원격서버는 원격서버에서 관리) # systemctl restart rsyslog # systemctl restart sshd SFTP로 접속해보면 아래와 같이 로깅이 적재되는 것을 볼 수 있다. Nov 24..

Linux/Security 2019.11.24

[Linux-Security] [CentOS 7] pam_wheel.so 모듈을 이용한 su 명령어 권한 제한

pam_wheel.so 모듈 : PAM의 주요 모듈 중 하나로 root 권한을 얻을 수 있는 사용자를 wheel 그룹에 묶어서 사용할 수 있도록 지원하는 모듈 /etc/pam.d/su 파일에서 [ auth required pam_wheel.so use_uid 주석해제 ] # cat /etc/pam.d/su #%PAM-1.0 auth sufficient pam_rootok.so # Uncomment the following line to implicitly trust users in the "wheel" group. #auth sufficient pam_wheel.so trust use_uid # Uncomment the following line to require a user to be in the "..

Linux/Security 2019.10.11

[Linux-Security] [CentOS 7] pam_tally2.so 모듈을 이용한 계정 잠금 임계값 설정 및 해제 System Admin

PAM의 pam_tally2.so : 로그인 시도 횟수를 카운트 하는 모듈로 실패시 관리해주는 역할 수행 옵션 설명 deny = 숫자 로그인 시도가 숫자만큼 실패하면 접근 차단 unlock_time = 숫자 일정 횟수 이상 로그인에 실패 했을 때, 숫자만큼 접근 차단 lock_time = 숫자 로그인 실패 후 숫자동안 접근 차단 예시) 계정로그인 5회 실패시 120초간 계정잠금 # cat /etc/pam.d/system-auth #%PAM-1.0 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. auth required pam_env.so auth sufficient pam_fpri..

Linux/Security 2019.08.30

[Linux-Security] iptables 방화벽 차단 로그 모니터링

리눅스의 iptables 방화벽을 이용하여 단순히 불필요한 접근을 차단하는 데에 그치지 않고, 로그를 남기고 모니터링을 하는 방법을 알아보겠다. 특정 웹 서버가 있고, 해당 웹 서버에 원치 않는 IP의 인바운드 인입을 차단 /etc/sysconfig/iptables 파일에 아래와 같이 추가 -A INPUT -j LOG --log-prefix "Deny_INPUT : " --log-level 4 * 로그생성시 접두어는 "Deny_INPUT" 로그 분석시 접두어를 이용하여 출력 * 로그 레벨은 Warning * /var/log/messages에 생성 -A INPUT -s 10.10.X.X -p tcp --dport 443 -j DROP * 샘플로 특정IP의 443인입 차단 Severity Level (로그 ..

Linux/Security 2019.07.25