#!/bin/bash ################################################################################ ############################## loggedip ####################################### ## Gets the last logged ip through ssh or any other method #Created by fahad saeed # cp /var/log/secure /home/script1 # gets the last accepted connection through ssh #ip of interest lies in file2 (ip that logged in) grep Accepted /home/script1/secure>/home/script1/file1 tail -1 /home/script1/file1>/home/script1/file2 sed 's/[ ][ ]*/\ /g' /home/script1/file2>/home/script1/file3 sed 's/[:]/\ /g' /home/script1/file3>/home/script1/file4 #now isolating ip of the incoming connection ipvar="" grep 192.168 /home/script1/file4>/home/script1/ip rm -f /home/script1/secure rm -f /home/script1/file1 rm -f /home/script1/file2 rm -f /home/script1/file3 rm -f /home/script1/file4