게시물 261건
   
[redhat] history 시간과 IP정보 남기는 설정 방법
글쓴이 : 젬젬젬 날짜 : 2015-04-30 (목) 16:02 조회 : 4573
1. 설정방법
# vi /etc/profile
...(중략)...
# [History User Trace & Time Log Config]
where=`who am i | sed -e 's/(//' -e 's/)//' | awk '{print $1"@"$5"_"}'`
today=`date +%Y%m%d%H%M`
file=$where$_$today.log
/bin/mkdir -p /var/log/who
/bin/touch /var/log/who/$file
export HISTSIZE=10000
export HISTTIMEFORMAT="%F %T : "
export HISTFILE=/var/log/who/$file
echo "[HISTORY USER TRACE & TIME LOG CONFIG ENABLED]" >&1
echo "[History file : $HISTFILE ]"


2. 확인 및 테스트
Connecting to xxx.xxx.xxx.xxx:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

############################################################
#                                                          #
#All connetions are monitored and recored                  #
#Disconnect IMMEDIATELY if you are not an authorizes user! #
#                                                          #
############################################################
Last login: Thu Apr 30 13:59:28 2015 from xxx.xxx.xxx.xxx
############################################################
#                                                          #
#All connetions are monitored and recored                  #
#Disconnect IMMEDIATELY if you are not an authorizes user! #
#                                                          #
############################################################
[HISTORY USER TRACE & TIME LOG CONFIG ENABLED]
[History file : /var/log/who/root@xxx.xxx.xxx.xxx_201504301404.log ]

# tail -f /var/log/who/root@xxx.xxx.xxx.xxx_201504301404.log
# cat /var/log/who/root@xxx.xxx.xxx.xxx_201504301404.log
# history
    1  2015-04-30 14:04:34 : tail -f /var/log/who/root@xxx.xxx.xxx.xxx_201504301404.log
    2  2015-04-30 14:04:40 : cat /var/log/who/root@xxx.xxx.xxx.xxx_201504301404.log
    3  2015-04-30 14:04:47 : history
# pwd
/var/log/who
# ll
total 20
-rw-r--r-- 1 root root   0 Apr 30 12:56 root@xxx.xxx.xxx.xxx_201504301256.log
-rw-r--r-- 1 root root 388 Apr 30 13:25 root@xxx.xxx.xxx.xxx_201504301259.log
-rw-r--r-- 1 root root 282 Apr 30 14:33 root@xxx.xxx.xxx.xxx_201504301404.log
-rw-r--r-- 1 root root 107 Apr 30 14:47 root@xxx.xxx.xxx.xxx_201504301445.log
-rw-r--r-- 1 root root   0 Apr 30 14:47 root@xxx.xxx.xxx.xxx_201504301447.log
-rw-r--r-- 1 root root  17 Apr 30 14:19 root@xxx.xxx.xxx.xxx_201504301359.log

이름 패스워드
비밀글 (체크하면 글쓴이만 내용을 확인할 수 있습니다.)
왼쪽의 글자를 입력하세요.
   

miwit.com sir.co.kr DNS Powered by DNSEver.com DNS Powered by DNSEver.com