Pages

2.25.2013

RSYSLOG: Disable Rate-limiting

This is a quick post about a security mechanism that was being a pain-in-the-arse so like any good SA I just disabled it.

I was consistently receiving this message in /var/log/messages when trying to fix a configuration issue with snort:
rsyslogd-2177: imuxsock begins to drop messages from pid 12490 due to rate-limiting

To allow any process unlimited logging to syslog add the following line to /etc/rsyslog.conf:
$SystemLogRateLimitInterval 0

Then to restart the service (on Centos/RHEL/Fedora) run:
service rsyslog restart

2.19.2013

Write Failed: Broken Pipe

I was having this issue today about every 2-5 minutes when connecting to my local ssh server from a Ubuntu 12.04 desktop. After some quick googling I found this little nugget that I thought I'd share.

Add this line to your /etc/ssh/ssh_config file on your client machine in my case the Ubuntu desktop:

ServerAliveInterval 120

Send root's mail to someone else using aliases

PURPOSE:
This is helpful if you want the root account's mail to go to another system or email address. 

ENVIRONMENT:
  • Centos 6
  • 2.6.32-279.22.1.el6.i686
  • postfix-2.6.6-2.2.el6_1.i686

PROCEDURES:
First things first make sure that postfix is configured correctly for root to send recieve mail. 

See this post about configuring postfix to relay mail through gmail:
http://systemstuds.blogspot.com/2013/02/postfix-configured-to-send-mail-through.html

Now that you have postfix set up correctly run: vi /etc/aliases

Press: shift+g (this vi trick will take you to the last line of the file)

Press: o (this will take you into edit mode below the cursor)

Now add a line to look like this: 
root: someemailaddress@gmail.com

Press: :wq (to save an quit the file)

Next, run: newaliases

Newaliases rebuilds the random access data base for the mail aliases file /etc/aliases. It must be run each time this file is changed in order for the change to take effect. (man page)

Finally, test your new configuration:  mail root

You should now see your test mail in your email account.

As always check /var/log/maillog for problems if you didn't recieve the email.

Good Luck!

Postfix configured to send mail through gmail as relay host

This is going to be my first blog post so cut me some slack. These posts will become more professional as the blog matures.

PURPOSE:
Why do this? I wanted my home Linux server to send me logwatch logs, alerts and shit to my personal gmail account. I wanted to use postfix since it’s the resident smtp server and didn’t feel the need to install any additional garbage.

ENVIRONMENT:
  • Centos 6
  • 2.6.32-279.22.1.el6.i686
  • postfix-2.6.6-2.2.el6_1.i686
PROCEDURES:
First, make sure the following lines exist in your /etc/postfix/main.cf (the most important lines are bold):
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = localhost
inet_protocols = all
myhostname = kong.example.com
mydestination = kong.example.com
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
 
debug_peer_level = 2
debugger_command =
     PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
     ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

##########
# Forward mail through Gmail
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/pki/tls/cert.pem


Next, create the /etc/postfix/sasl_passwd file with the following one liner:
[smtp.gmail.com]:587 crazyemailaddress@gmail.com:cr@zypas$word

Next, run this command: sudo postmap /etc/postfix/sasl_passwd
That will create the sasl_passwd.db file.


IMPORTANT SECURITY TIP: Make sure you give full ownership to root with 600 permissions because your email credentials will be stored in cleartext.

Restart your mail server: service postfix restart

Extra step for root mail forwarding using aliases:
http://systemstuds.blogspot.com/2013/02/send-roots-mail-to-someone-else-using.html

Finally, test your configuration:
mail someemailaddress@gmail.com

If you didn’t receive the email check your /var/log/maillog for problems. I had a certificate issue my first go round. Then I had to check that gmail didn’t lock my account out for sending too much spam :P
Good Luck!