LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-30-2011, 05:27 AM   #1
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131
Blog Entries: 1

Rep: Reputation: 3
Email Notification not working for AIDE, Samhain and OSSEC in Ubuntu


Greeting LQ, I have a problem with my Email Notification. I'm not being able to get any email notification.

#

#-------------------------------Samhain Mail-------------------------------------#

#

ERROR : [2011-12-29T22:49:44+0000] msg=<Bad response (530 5.7.0 Must issue a STARTTLS command first. g12sm20110313wiw.10), expected 250>, subroutine=<sh_mail_wait>, service=<mail>, host=<SMTP server>

ERROR : [2011-12-29T22:49:44+0000] msg=<MAIL FROM failed>, subroutine=<sh_mail_start_conn>, service=<mail>, host=<daemon@example.com>

ERROR : [2011-12-29T22:49:44+0000] msg=<Service failure>, service=<mail>, obj=<example@gmail.com>

#

#-------------------------------------------------------------------------------#

#

#
#--Samhain (Later I tried using my ISP SMTP and yet it didn't work--------------#
#

ERROR : [2011-12-30T11:00:47+0000] msg=<Connection refused, address smtp.virginmedia.com>, subroutine=<connect>, service=<email>, host=<smtp.virginmedia.com>
ERROR : [2011-12-30T11:00:47+0000] msg=<Cannot remove stale lock file, PID may be a running process>, subroutine=<sh_unix_test_and_lock>
ERROR : [2011-12-30T11:00:47+0000] msg=<Service failure>, service=<mail>, obj=<xxxxxxx@yahoo.com>
#
#-------------------------------------------------------------------------------#
#




#

#-----------------------------OSSEC Mail Problem-------------------------------#

#

2011/12/26 22:32:43 os_sendmail(1764): WARN: Mail from not accepted by server

2011/12/26 22:32:43 ossec-maild(1223): ERROR: Error Sending email to 76.x.x.x (

smtp server)

#

#-------------------------------------------------------------------------------#

#







I get some kind of error.

In my configuration file /etc/samhainrc I changed following things.



MailSeverity=warn

SetMailAddress=xxxxxxx@gmail.com

SetMailRelay = smtp.gmail.com or kept IP address and instead of Notification I get this error shown below.



ERROR : [2011-12-29T22:49:44+0000] msg=<Bad response (530 5.7.0 Must issue a STARTTLS command first. g12sm20110313wiw.10), expected 250>, subroutine=<sh_mail_wait>, service=<mail>, host=<SMTP server>



ERROR : [2011-12-29T22:49:44+0000] msg=<MAIL FROM failed>, subroutine=<sh_mail_start_conn>, service=<mail>, host=<daemon@example.com>



ERROR : [2011-12-29T22:49:44+0000] msg=<Service failure>, service=<mail>, obj=<xxxxxxx@gmail.com>





I really need help with this. I would really appreciate it.


I didn't get AIDEs ERROR mesg but I'm sure if I can figure out on of them then that would be my solution to all these three Host-based Intrusion Detection System.
 
Old 12-30-2011, 05:54 AM   #2
klearview
Member
 
Registered: Aug 2006
Location: London
Distribution: Debian, Kubuntu
Posts: 572

Rep: Reputation: 75
Not sure if this will help but for Gmail you need to specify gmail-smtp-in.l.google.com rather than smtp.gmail.com
 
Old 12-30-2011, 06:51 AM   #3
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
Thanks though it didn't work.
 
Old 12-30-2011, 07:13 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Check if you can send email from the commandline.

Code:
echo 'This is a test email' | mail -s 'Test E-Mail' your_email_address@your_email_provider.tld
I'm not so sure about the option within /etc/samhainrc
Code:
SetMailRelay = smtp.gmail.com
a Relay normaly just takes mails and then tries to send them. And normaly it only allows this to happen from certain servers...
What happens if comment it out? What was the original value?
 
Old 12-30-2011, 07:29 AM   #5
agentbuzz
Member
 
Registered: Oct 2010
Location: Texas
Distribution: Debian, Ubuntu, CentOS, RHEL
Posts: 131

Rep: Reputation: 25
530 error talking to gmail

metalaarif,
An SMTP code 530 means you have to communicate with the foreign SMTP peer using SSL/TLS. See this link to find SMTP commands, reply codes, and the RFCs governing SMTP generally. You will need to configure the local MTA to conduct the SMTP dialog with GMail over SSL. If you ask a separate question about SMTP over SSL and post your MTA's configuration, someone will be able to help you with your problem.
 
Old 12-30-2011, 11:25 AM   #6
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
Quote:
echo 'This is a test email' | mail -s 'Test E-Mail' your_email_address@your_email_provider.tld
Thanks zhjim but it didn't seem to work but learned something new and I even tried what you recommended but it didn't seem to work.

And your right agentbuzz it was interesting reading those SMTP commands. And I agree that local MTA or mail server does the work of sending mails but the thing I don't understand is why isn't it connected with anything like that. I read the documentation and even in configuration files there's nothing mentioned about configuring MTA or mail server. Why does each HIDS configuration file contains MAIL configuration part.
This is Samhain Configuration
Quote:
## --- E-Mail ---

# Only highest-level (alert) reports will be mailed immediately,
# others will be queued. Here you can define, when the queue will
# be flushed (Note: the queue is automatically flushed after
# completing a file check).
#
# SetMailTime = 86400

## Maximum number of mails to queue
#
# SetMailNum = 10

## Recipient (max. 8)
#
SetMailAddress=xxxxxx@gmail.com

## Mail relay (IP address)
#
SetMailRelay = gmail-smtp-in.l.google.com

## Custom subject format
#
MailSubject = Threats

## --- end E-Mail ---
 
Old 12-30-2011, 02:20 PM   #7
agentbuzz
Member
 
Registered: Oct 2010
Location: Texas
Distribution: Debian, Ubuntu, CentOS, RHEL
Posts: 131

Rep: Reputation: 25
Samhain, MTA config

metalaarif,

I missed that item in your Samhain config earlier. Set "SetMailRelay" to the local mail server. In your case, perhaps that is the same server on which you are running Samhain. Otherwise, it could be an MTA on your LAN that can relay outbound mail. There should be some mail server on your network that can create SMTP connections to Internet hosts. If there is such a local mail server, change your config to point to it and your problem is solved. If not, we will need to see some local SMTP server's config, whether that is sendmail, postfix, qmail, or exim, so that we can show you how to authenticate with the GMail server over TLS.
 
Old 12-30-2011, 05:03 PM   #8
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
Hmm, that sounds great, I'll start doing that right away.
Actually I'm doing this test on my Virtual Machine Vmware.
I think I'll try to create a local mail server and point it towards it so that i receive mail on my localhost itself and if I succeed and later on try i'll try to redirect it to gmail or yahoomail server as u have mentioned. I think it should work as you said "agentbuzz".
By the way I don't want to close this thread yet, I want to try it myself once and then if I succeed I'll mark it as solved.
 
Old 12-31-2011, 03:49 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Moved: This thread is more suitable in the Linux General forum (as it is not a Linux Security issue) and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 12-31-2011, 07:12 AM   #10
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
I have configured Postfix mailServer and I even configured GmailPostfixFetchmail.
Now when I try
Quote:
echo 'This is a test email' | mail -s 'Test E-Mail' xxxxxx@gmail.com
I receive email in my gmail account

In my Postfix
myhostname = localhost
relayhost = [smtp.gmail.com]:587

When I changed my /etc/samhianrc to
SetMailAddress=xxxxxx@gmail.com
SetMailRelay= smtp.gmail.com

I got this error when I ran # samhain -t check -p warn --foreground
Quote:
ERROR : [2011-12-26T14:52:29+0000] msg=<Bad response (530 5.7.0 Must issue a STARTTLS command first. fq7sm43042773wbb.1), expected 250>, subroutine=<sh_mail_wait>, service=<mail>, host=<SMTP server>
ERROR : [2011-12-26T14:52:30+0000] msg=<MAIL FROM failed>, subroutine=<sh_mail_start_conn>, service=<mail>, host=<daemon@example.com>
ERROR : [2011-12-26T14:52:30+0000] msg=<Service failure>, service=<mail>, obj=<xxxxxxx@gmail.com>
then I again changed my /etc/samhianrc to
SetMailAddress=xxxxxx@localhost.com
SetMailRelay= 127.0.0.0

I got this error when I ran # samhain -t check -p warn --foreground
Quote:
ERROR : [2011-12-26T14:45:20+0000] msg=<Network is unreachable, address 127.0.0.0>, subroutine=<connect>, service=<email>, host=<127.0.0.0>
ERROR : [2011-12-26T14:45:20+0000] msg=<Service failure>, service=<mail>, obj=<xxxxxxx@localhost.com>
then I again changed my /etc/samhianrc to
SetMailAddress=xxxxxx@localhost
SetMailRelay= localhost

I got this error when I ran # samhain -t check -p warn --foreground
Quote:
ERROR : [2011-12-26T14:54:52+0000] msg=<Bad response (550 5.1.1 <xxxxxxxx@localhost>: Recipient address rejected: User unknown in local recipient table), expected 250>, subroutine=<sh_mail_wait>, service=<mail>, host=<SMTP server>
ERROR : [2011-12-26T14:54:52+0000] msg=<RCPT TO failed>, subroutine=<sh_mail_start_conn>, service=<mail>, host=<xxxxxxx@localhost>
ERROR : [2011-12-26T14:54:52+0000] msg=<Service failure>, service=<mail>, obj=<xxxxxxx@localhost>
I got 550 error and 550 error means
Quote:
Requested action not taken: mailbox unavailable.
I'm so confused now anyway do u think that i need to create a mailbox for postfix (mbox which is postfix defaul mailbox)

Last edited by metalaarif; 12-31-2011 at 07:55 AM.
 
Old 01-02-2012, 03:33 AM   #11
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by metalaarif View Post
I have configured Postfix mailServer and I even configured GmailPostfixFetchmail.
Now when I try
I receive email in my gmail account
That means the local mail server is working. So we have to care about samhain. (As you already did)

Quote:
Originally Posted by metalaarif View Post
When I changed my /etc/samhianrc to
SetMailAddress=xxxxxx@gmail.com
SetMailRelay= smtp.gmail.com
Use your local mail server as the relay. (As you also did)
Quote:
Originally Posted by metalaarif View Post
then I again changed my /etc/samhianrc to
SetMailAddress=xxxxxx@localhost.com
SetMailRelay= 127.0.0.0
Just a typo the localhosts address is 127.0.0.1.
Quote:
Originally Posted by metalaarif View Post
then I again changed my /etc/samhianrc to
SetMailAddress=xxxxxx@localhost
SetMailRelay= localhost

I got this error when I ran # samhain -t check -p warn --foreground
To me it looks like the user your sending the email from is not allowed inside your local mail server. Do you use anothrer user to send samhain mails? What happens if you run the echo 'test mail' | mail -s "test mail" as the user that you run samhain as?
 
Old 01-02-2012, 07:10 AM   #12
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
Thanks zhjim your great but actually I would have done it myself too but i got frustrate and didn't think of putting 127.0.0.1
It works.

Take a look, this is how I configured to make it running
http://www.linuxquestions.org/questi...e-ossec-34342/

Last edited by metalaarif; 01-02-2012 at 07:21 AM. Reason: Providing link to my blog
 
Old 01-02-2012, 10:30 AM   #13
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Just answering forum threads Great you got it figured.

Also don't forget to mark the thread as solved. Use the thread tools button on the start of the thread.
 
Old 01-02-2012, 12:05 PM   #14
.rainer
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 1
Quote:
Originally Posted by metalaarif View Post

then I again changed my /etc/samhianrc to
SetMailAddress=xxxxxx@localhost
SetMailRelay= localhost
Of course this can't work. You are asking your local MTA to deliver the email to the local mailbox xxxxxx, which presumably doesn't exist. What you want is to send mail to xxxxxx@gmail.com and relay it through your own MTA, so the correct version is:

SetMailAddress=xxxxxx@gmail.com
SetMailRelay= localhost
 
Old 01-05-2012, 11:19 AM   #15
metalaarif
Member
 
Registered: Oct 2011
Location: Nepal
Distribution: RHEL, CentOS, Slackware
Posts: 131

Original Poster
Blog Entries: 1

Rep: Reputation: 3
Thanks .rainer that worked too
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios - email notification - How to receive alert email? kumaran1983 Linux - Newbie 4 10-20-2011 06:12 AM
[SOLVED] Anyone familiar with samhain on Debian/Ubuntu? sneakyimp Linux - Security 4 07-24-2011 05:59 PM
what can or can't OSSEC do compare to samhain? kissfreeman Linux - Newbie 3 06-19-2008 07:56 AM
Can someone post a sample aide.conf file here? For AIDE IDS abefroman Linux - Security 9 04-12-2008 08:18 AM
Email notification jeremy LQ Suggestions & Feedback 6 11-07-2002 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:49 PM.

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