Linux 47

[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

[ Centos 5 ~ 6 ] chkconfig를 이용하여 서비스 자동실행 등록

샘플로 ntpd 서비스를 런레벨 3 부팅시 자동실행될 수 있게 서비스 등록을 해보겠다. 1. ntpd 서비스 서버부팅시 런레벨별 ntpd OFF 확인 # ls /etc/rc3.d | grep ntpd K74ntpd # chkconfig --list ntpd ntpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제 2. 런레벨 3 부팅시 ntpd 자동시작 변경 # chkconfig --level 3 ntpd on # chkconfig --list ntpd ntpd 0:해제 1:해제 2:해제 3:활성 4:해제 5:해제 6:해제 # ls /etc/rc3.d | grep ntpd S58ntpd

Compression Comparison of gzip and 7z on CentOS 7. (CentOS 7에서 gzip과 7z 압축 비교)

윈도우 플랫폼에서만 7z을 써봤지만 리눅스에서도 설치가 가능하여 설치하고, 몇 개 로그성 파일을 압축해 보고 gzip과 비교하여 압축율을 보았다. p7z 설치 # yum install epel-release # Extra Packages for Enterprise Linux 저장소 설치 # yum install p7zip p7zip-plugins # 7z | grep Version p7zip Version 16.02 Sample Log 324448621 Sep 11 02:03 2019-09-10.log 285908878 Sep 16 16:53 2019-09-16.log 381334202 Sep 26 16:20 2019-09-26.log 376169644 Sep 28 14:13 2019-09-28.log ..

Linux Access log 일 단위 자동압축 쉘 스크립트

리눅스 파일시스템 용량이 넉넉하면 괜찬지만 지속적인 용량관리가 필요하다면 로그를 압축보관할 필요가 있다. 이번 포스팅은 엑세스 로그가 일 단위로 생성되면, 전일(yesterday) 로그를 자동으로 백업할 수 있는 간단한 쉘 스크립트를 알아보겠다. date명령어를 이용하여 전일 날짜를 출력 date명령어의 -d 옵션을 이용하여 전일 날짜 출력. (현재일 2019년 10월 16일 기준) # date -d 'yesterday' Tue Oct 15 07:37:07 EDT 2019 로그포맷(yyyy-dd-mm)에 맞게 출력 # date +%Y'-'%m'-'%d -d 'yesterday' 2019-10-15 로그포맷에 맞는 gzip 압축 명령어 완성하기 대상파일 : localhost_access_log.2019-1..

Linux/Shell Script 2019.10.16

Linux 배너파일(issue, issue.net, motd)과 ssh 배너설정

파일 내용 /etc/issue 사용자가 로그인할 때, "login: " 메세지를 보여주기 전에 보여지는 메세지 . (로컬 터미널) /etc/issue.net 사용자가 로그인할 때, "login: " 메세지를 보여주기 전에 보여지는 메세지 . (Telnet) /etc/motd 로그인이 성공되었을 때 보여지는 메세지. (Telnet, SSH) /etc/issue.net # cat /etc/issue.net issue.net massge test login: 메세지전 issue.net massge test 메세지 출력 login: Password: /etc/motd # cat /etc/motd motd msg test 로그인 성공 후 "motd msg test" 메세지 출력 motd msg test $ 요즘 ..

[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 history 명령어 실행일시 표시하기

간단히 환경변수를 추가하여 간단하게 history 명령어에 실행일시를 표시할 수 있다. 전역 적용시) /etc/Profile 파일 맨 아래 명령어 추가 root만 적용시) /root/.bash_profile 파일 맨 아래 명령어 추가 --------------------------------------------------------------------------- export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S" --------------------------------------------------------------------------- 적용후 재로그인을 하고 history 명령어를 실행하면 아래와 같은 포맷으로 출력된다. 973 2019-10-07_17:05:10 ..