Sunday, August 17, 2014

Secure SSHD in Linux

The secure shell daemon should be hardened to prevent unauthorised access before being put into a production environment or exposed to the internet.


Verify the /etc/ssh/sshd_config file contains the following lines and that they are not commented out:
 
Protocol 2
IgnoreRhosts yes
HostbasedAuthentication no
PermitRootLogin no
PermitEmptyPasswords no
AllowTcpForwarding no (unless needed)
X11 Forwarding no (unless needed)
AllowUsers <username1> <username2> (Optional)
DenyUsers <username1> <username2> (Optional)

Friday, August 15, 2014

How to Enable logging of email’s subject in Postfix maillog

By default postfix only capture ‘From’ and ‘To’ details in the log file (/var/log/maillog). There are some scenarios where we want that email’s subject should be capture in the maillog. In this article we will discuss how to achieve this :
We are assusming that postfix is already up and running and will make below changes.
 
Step:1 Edit ‘/etc/postfix/main.cf’ file & uncomment below line:
#header_checks = regexp:/etc/postfix/header_checks
 
Step:2 Append the below line in ‘/etc/postfix/header_checks’
/^Subject:/     WARN
 
Step:3 Restart the postfix server
#service postfix restart
#postmap /etc/postfix/header_checks

 
Step:4 Now do testing and send a test mail & see the logs
mailsending-using-telnet
As we can see above , that info user has send email to gmail id with the subject "Linux Interview Call Details" .
Now see the maillogs using the command 'tailf /var/log/maillog'
maillog-with-email-subject

Monday, August 4, 2014

Use Iptables in RHEL7 / CentOS7

 RHEL 7 / CentOS 7 new services, Firewalld is bit complicated . So decided not to use firewalld at least as of now and wanted to continue with iptables commands as I was using in RHEL / CentOS 5 and 6.

However in RHEL 7 / CentOS 7, iptables will not be there andfound that I can still use the iptables by disabling firewalld service.
So, If you are in same condition as mine and you want to use iptables on CentOS / RHEL 7 instead of firewalld, Please follow this howto.
Firewall
Firewall
As we all know that, CentOS / RHEL 7 both are completely systemd based, So We will have to use few systemd related commands to disable firewalld and enable iptables service.
1. Disable Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl mask firewalld
2. Stop Firewalld Service.
[root@rhel-centos7-tejas-barot-linux ~]# systemctl stop firewalld
3. Install iptables service related packages.
[root@rhel-centos7-tejas-barot-linux ~]# yum -y install iptables-services
4. Make sure service starts at boot:
[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable iptables
# If you do not want ip6tables, You can skip following command.
[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable ip6tables
5. Now, Finally Let’s start the iptables services.
[root@rhel-centos7-tejas-barot-linux ~]# systemctl start iptables
# If you do not want ip6tables, You can skip following command.
[root@rhel-centos7-tejas-barot-linux ~]# systemctl start ip6tables
Firewalld Service is now disabled and stop, You can use iptables.
Now, You will be able to use iptables as your firewall, You can add / remove rules as you were doing in previous releases of Red Hat / CentOS 5 and 6, You can configure firewall with iptables in same manner as previous.