It is currently Tue May 22, 2018 3:38 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.


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

Joined: Wed May 03, 2006 2:05 pm
Posts: 273
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.

 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.

 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

if [ -n "$SSH_CONNECTION ] ; then
   IP="$(echo "$SSH_CONNECTION" | cut -d\  -f1)"
   echo "Subject: Login detected from $IP" | sendmail [email protected]

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.

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 7 guests

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:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group