#!/bin/bash
count=$(netstat -ntpa | grep ssh | grep -i EST* | wc -l)
if [ "$count" -gt 0 ]; then
comm=$(netstat -ntpa | grep ssh | grep -i EST* | awk '{print $7}' |
cut -d "/" -f1 > /tmp/ssh_1)
for ID in `cat /tmp/ssh_1`
do
user=`who -a | grep -ih "\W*\w*$ID\w*\W*" | grep -w $ID | awk
'{print $1}'`
IP=`who -a | grep -i $ID | awk '{print $8}' | cut -d "(" -f2 |
cut -d ")" -f1`
Date=`who -a | grep -i $ID | awk '{print $4,$6}'`
cat << EOF
Date-Time :- $Date
username :- $user
IPAdd:- $IP
====================
EOF
done
else
echo "No ssh connection in Host"
fi
count=$(netstat -ntpa | grep ssh | grep -i EST* | wc -l)
if [ "$count" -gt 0 ]; then
comm=$(netstat -ntpa | grep ssh | grep -i EST* | awk '{print $7}' |
cut -d "/" -f1 > /tmp/ssh_1)
for ID in `cat /tmp/ssh_1`
do
user=`who -a | grep -ih "\W*\w*$ID\w*\W*" | grep -w $ID | awk
'{print $1}'`
IP=`who -a | grep -i $ID | awk '{print $8}' | cut -d "(" -f2 |
cut -d ")" -f1`
Date=`who -a | grep -i $ID | awk '{print $4,$6}'`
cat << EOF
Date-Time :- $Date
username :- $user
IPAdd:- $IP
====================
EOF
done
else
echo "No ssh connection in Host"
fi
No comments:
Post a Comment