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

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:
# $OpenBSD: dot.profile,v 1.4 2005/02/16 06:56:57 matthieu Exp $
# sh/ksh initialization

PS1='Enter your command: '
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification'
from: garry <>
Subject: SSH Login Notification

Someone from logged into 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.

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