View Single Post
  #6   (View Single Post)  
Old 1st July 2018
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 472
Default

Experimented with the script, ended up putting it in my ~/.profile and it seems to work,
I just tried on a "localhost" situation, and it does send me a e-mail notice:
/home/garry/.profile
Code:
# $OpenBSD: dot.profile,v 1.4 2005/02/16 06:56:57 matthieu Exp $
#
# sh/ksh initialization

PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:.
export PATH HOME TERM
PS1='Enter your command: '
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' garry@garry.garry.org
Quote:
from: garry <garry@garry.garry.org>
To: garry@garry.garry.org
Subject: SSH Login Notification

Someone from 127.0.0.1 logged into garry.garry.org on 30 Jun 2018, Sat 09:10:51 PM.
I am not positive this is what the OP is looking for though.
========== edit
I also tried it on my server, and used my regular e-mail address at a external e-mail service,
works great, sent me a e-mail, including the ip I logged in with.

Quote:
I'm sure some security graybeard will come along and tell me why this is all silly and not adding to my security and that's fine, too :-)
As far as security goes, it does nothing to improve security, if your security is good, you do not need to worry about any one besides you, or who ever is authorized logging in.
By the time you check your e-mail, who ever logged in would have done what they want to do and logged out again.
But any way, you would have a e-mail letting you know they logged in,... and you would then also know you had a security problem, it would be better just to make sure it is secure, and nobody else besides you can gain ssh access and login
__________________
My best friends are parrots

Last edited by PapaParrot; 1st July 2018 at 03:08 AM.
Reply With Quote