LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-13-2018, 07:23 PM   #1
sniper8752
Member
 
Registered: Oct 2012
Posts: 564

Rep: Reputation: Disabled
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.
 
Old 02-13-2018, 10:32 PM   #2
Elizine
Member
 
Registered: Aug 2015
Posts: 54
Blog Entries: 1

Rep: Reputation: Disabled
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
 
1 members found this post helpful.
Old 02-14-2018, 10:00 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Elizine View Post
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.
 
Old 02-15-2018, 05:49 PM   #4
sniper8752
Member
 
Registered: Oct 2012
Posts: 564

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Elizine View Post
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.
 
Old 02-15-2018, 05:50 PM   #5
sniper8752
Member
 
Registered: Oct 2012
Posts: 564

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Elizine View Post
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?
 
Old 02-15-2018, 07:43 PM   #6
glider010
LQ Newbie
 
Registered: Feb 2018
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by sniper8752 View Post
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

Last edited by jefro; 02-20-2018 at 01:10 PM. Reason: Unknown link by new user
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
System Authentication using centralized OpenLDAP(local login and ssh login) narayanab16 Linux - Server 3 05-21-2016 12:45 PM
[SOLVED] Fast login via ssh / Slow login via login manager with machine in AD-domain c01d Linux - Server 2 03-01-2016 01:52 AM
[SOLVED] SSH login problem for additional users after password-less login setup uncle-c Linux - Newbie 3 02-10-2010 12:51 PM
Trying to send system notifications via SSH to computers on LAN. uncertain Programming 13 08-15-2009 04:56 PM
Dropline's GDM's login has pop up notifications davidguygc Slackware 0 08-24-2007 07:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration