Register
It is currently Fri Dec 19, 2014 8:36 pm

Script to warn me when someone accesses the machine remotely


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Mar 01, 2012 4:25 pm   

Joined: Fri Nov 19, 2010 2:04 pm
Posts: 4
I had another employee where I work log in to my machine remotely and reboot it.
I would like to be able to find a script or something that would warn me via email or some
other method when someone logs on to my computer remotely so that I might be able to stop them from rebooting my machine or kick them out of my machine before they can do any damage.

Thanks


Top
 Profile  
 PostPosted: Fri Mar 09, 2012 12:49 pm   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hello dtigue!

There are a few different ways you can do this... Here are two!

1) You could run a cron job every few minutes that compares the output of the 'last' command between runs.

2) You could run something in the background that continuously tails the logs (/var/log/secure?) for a more real-time approach.

I hope this gives you a starting point! Let us know if you have any more questions.


Top
 Profile YIM  
 PostPosted: Sat Mar 10, 2012 12:08 am   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
a password and/or account audit seems more in order.


Top
 Profile WWW  
 PostPosted: Tue Jul 03, 2012 4:33 am   

Joined: Tue Jul 03, 2012 4:22 am
Posts: 1
I know this is a little late, but I'm posting this for future readers

You can add something simple like this to your ~/.profile or ~/.bash_profile

Code:
if [ -n "$SSH_CONNECTION ] ; then
   IP="$(echo "$SSH_CONNECTION" | cut -d\  -f1)"
   echo "Subject: Login detected from $IP" | sendmail your@email.com
fi


It's of course possible for the remote machine to prevent itself from reading the ~/.profile file

The sendmail line implies you have that up and running too. You could replace it with any type of notification you want. mutt, xmessage, or a sound file.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP