Linux Server Security Tutorial Part 1

This article will help people securing their Linux web server. Its very essential to follow the steps below to protect your server from attacks and vulnerabilities.

Follow the steps below to perform security task (OS Centos):-

1) Install a firewall to monitor you incoming and outgoing traffic. Make rules within it to block illegal usage. I would recommend you to use APF or CSF

Read here about CSF:-
Read here about APF:-

Installation Guide:-

2) Check if their are updates for software installed. Its very necessary to update the software with the necessary patch.


yum check-update

Suppose it shows you list of update available then you need to run.

yum install update_name

(replace update_name is the software update available )

If you see result like no update available then it means your kernel and installed files are up-to-date

3) Change SSH port for logging. This is necessary step because an attacker can brute force ssh port to gain root access , so by changing SSH port from 22 to something anonymous like 132 or anything you would like, will hep you to secure your server.


vi /etc/ssh/sshd_config

Find line port 22 at the bottom of the the file and press “i” to edit the file and change port number to anything you would like. Then press “escape” and “:wq” to save the file.

Now you have to restart SSH


/etc/init.d/sshd restart

Make sure to add the port number in the firewall other wise it will block your SSH access.

4) Protect Against Fork Bombs. Fork bombs are programs that keep creating child processes until system resources are all used. They actually aren’t remote exploits because they require a local user to execute the bomb; however, users may be tricked into running a fork bomb. For example, the following example may look innocent, but running it on an unprotected system may take the whole system down


vi /etc/security/limits.conf

Add these two lines in the code:-

@users soft nproc 100
@users hard nproc 150

save it and you are done.If you don’t have a users group then check your accounts belong to which group or you can individually limit the user access also.

5) Install Rootkit Hunter (rkhunter).rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits. It does this by comparing MD5 hashes of important files with known good ones in online database, searching for default directories (of rootkits), wrong permissions, hidden files, suspicious strings in kernel modules, and special tests for Linux and FreeBSD.


tar -xzvf rkhunter-1.3.8.tar.gz
cd rkhunter-1.3.8

rukhunter will be installed on your server. Now you have to setup cron job and mail notification system


nano -w /etc/cron.daily/

Add the following text to

/usr/local/bin/rkhunter –versioncheck
/usr/local/bin/rkhunter –update
/usr/local/bin/rkhunter –cronjob –report-warnings-only
) | /bin/mail -s ‘rkhunter Daily Run (PutYourServerNameHere)’

Note:- You have to change PutYourServerNameHere and with your original server name and email address

The above were some ways to harden server protection.Soon I will be writing more on securing Linux Server.


A company providing web hosting solutions around globe...