LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ssh login notifications not being sent out (https://www.linuxquestions.org/questions/linux-software-2/ssh-login-notifications-not-being-sent-out-4175623701/)

sniper8752 02-13-2018 07:23 PM

ssh login notifications not being sent out
 
I set up ssh so that when a user logs in, a notification is sent out. The file is in /etc/ssh. It is sshrc. I notice that when I login from my lan to my internal interface on the server, I get a notification. But when I am connecting from the wan to the wan interface, there is no notification sent out.

Elizine 02-13-2018 10:32 PM

Did you follow the steps as below?

Open the file ~/.bashrc in a text editor.

Append the following lines:

Code:

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' YOUR_EMAIL_ADDRESS


Habitual 02-14-2018 10:00 AM

Quote:

Originally Posted by Elizine (Post 5819643)
Code:

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' YOUR_EMAIL_ADDRESS


You rock! Good stuff, Maynard. :hattip:

sniper8752 02-15-2018 05:49 PM

Quote:

Originally Posted by Elizine (Post 5819643)
Did you follow the steps as below?

Open the file ~/.bashrc in a text editor.

Append the following lines:

Code:

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' YOUR_EMAIL_ADDRESS


Here is what I have in /etc/ssh/sshrc:

Code:

logger -t ssh-wrapper $USER login from $ip

echo "Subject: Login: Someone logged in" | sendmail -f "Server <user@hotmail.com>" -t "Someone <number@email.com>" &

I can try doing this as well.

sniper8752 02-15-2018 05:50 PM

Quote:

Originally Posted by Elizine (Post 5819643)
Did you follow the steps as below?

Open the file ~/.bashrc in a text editor.

Append the following lines:

Code:

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' YOUR_EMAIL_ADDRESS


Is there a way to apply this to all users, instead of having to do it for each individual one?

glider010 02-15-2018 07:43 PM

Quote:

Originally Posted by sniper8752 (Post 5820324)
Is there a way to apply this to all users, instead of having to do it for each individual one?

Look here, it's an alternative solution that works for all user.
removed


All times are GMT -5. The time now is 02:20 AM.