1,
mkdir /usr/local/proxy

cat proxy

#!/bin/bash
User=$USER
Ip=${SSH_CLIENT%% *}
Date="`date +%Y-%m-%d`"
Logfile=/var/log/myaudit/${User}_${Ip}_${Date}.log
#export Logfile=/var/log/myaudit/${User}_${Ip}_${Date}.log
export PROMPT_COMMAND='{ date "+%y-%m-%d %T ##### $(who am i |awk "{print \$1\" \"\$2\" \"\$5}")  #### $(history 1 | { read x cmd; echo "$cmd"; })"; } >>$Logfile'

2,
vi /etc/profile
加入以下行
source /usr/local/proxy/proxy