View Single Post
  #5   (View Single Post)  
Old 30th June 2018
PapaParrot's Avatar
PapaParrot PapaParrot is offline
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 472

Maybe I am misunderstanding as well, but any way, I would look at
 man login.conf
and then also the:
$ man motd
MOTD(5) File Formats Manual MOTD(5)

motd - message of the day
# Authpf accounts get a special motd and shell
Instead of, or as well as displaying a welcome message, maybe a command to send a e-mail could be added ?

Does the OP know about the "last" command ?
man last
LAST(1) General Commands Manual LAST(1)

last - indicate last logins of users, ttys, and hosts
The last utility will either list the sessions of specified users, ttys,
and hosts, in reverse time order, or list the users logged in at a
specified snapshot date and time in reverse time order. Each line of
output contains the user name, the tty from which the session was
conducted, any hostname, the start and stop times for the session, and
the duration of the session. If the session is still continuing or was
cut short by a crash or shutdown, last will so indicate.

The options are as follows:

-c Calculates the total time displayed and prints it after the

-d date Specify the snapshot date and time. All users logged in at
the snapshot date and time will be reported. This may be used
with the -f option to derive the results from stored wtmp
files. When this argument is provided, all other options
except for -f and -n are ignored. The argument should be in
the form "[[[CC]YY]MMDD]hhmm[.SS]" where each pair of letters
represents the following:
I use it quite a bit to see who and when the last person to login to the server is/was. But I have never felt a need to have it (the system) send me a e-mail every time I or someone else logs in. How ever it might be possible to write some kind of script that sends the "snapshot" to a e-mail address , or something .
It sounds to me like that is all the OP wants, is that a e-mail is sent to them when someone does login, so for example if some one logged it as the admin, somehow, the OP would receive a e-mail showing that, but it still does not make much sense to me, if the OP is the only one that will be logging in, nobody else will be logging in, it does not make sense to me why they need a e-mail to tell them they logged in.
If the OP can clarify better exactly what it is they need or want to do, it would help.
I found this, but it is for Linux, how ever it does not require "PAM", :
Open the file ~/.bashrc in a text editor.

Append the following lines:

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' YOUR_EMAIL_ADDRESS
The other thing, for example on my system, I am using ksh, instead of bash, there is no "bash" on my system, but it seems to me like the script could be modified for csh or ksh, depending,... or maybe you do use bash ?
I just now found this, and am not even sure this is what the OP is actually wanting, it seems like it is, any way, I have not had a chance to try modifying the script, there may be someone more expert then me that could help there, if it is what the OP wants to do.
My best friends are parrots

Last edited by PapaParrot; 1st July 2018 at 05:34 PM. Reason: spelling, punctuation
Reply With Quote