$200 Credit – New Customers ONLY – Chat with Sales Now!

By: Tommy Craddock

At Hivelocity we sell a few hundred Linux dedicated servers or Virtual Private Servers (VPS) every month.  As a hosting provider and data center with thousands of dedicated and virtual servers our techs are on site 24/7 assisting our customers as issues arise.  Many of the dedicated servers we deploy are “self-managed” which leaves the responsibility of maintaining securing a Linux server up to each customer.  Over the last decade plus of providing hosting services we have seen a wide range of security practices employed.  We thought it was a good idea to list a handful of “best practices” that we recommend for every Linux dedicated server.  If you employ each of the following security practices you will greatly reduce the risk of having your data compromised.  The other option is to add managed services to your server and allow us to handle things for you.

There are several Linux server “best practices” that Linux server administrators can follow to protect information from intruders. Unfortunately not all professionals are aware of these fairly simple tasks which include:

· Analyzing the system with root kit checker

· Creating a root login detector and emailer

· Setting an SSH MOTD

· Using secure SSH Logins

· Identifying nuke PHP shells

· Encrypting data

· Enable a firewall

 

Analyzing the System with Root Kit Checker

A common practice among hackers is to install a rootkit on Linux dedicated servers without the administrator being alerted. Some root kit programs are even coded to run at a specific time. Luckily there is a fairly easy method of checking for this issue. First, open up a terminal and type in the following:

Cd ~

wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

tar xvzf chkrootkit.tar.gz

cd chkrootkit-0.44

make sense

To execute, type:

~/chkrootkit-0.44/chkrootkit

This is an activity that should be run on a daily basis.

 

Creating a Root Login Detector and Emailer

This is a simple yet effective trick that warns the administrator if an intruder manages to use the admin login password on a server. The first step is to edit .bash_profile for the root. In a text editor, add the following line at the end of the file:

echo ‘ALERT – Root Shell Access on:’ `date` `who` | mail -s “Alert: Root Access from `who | awk ‘{print $6}’`” [email protected]

Replace [email protected] with the administer email address. Do not forget to the save the file prior to exiting.

 

Setting an SSH MOTD

Another excellent Linux server “best practices” method is to set up an SSH MOTD. This practice will provide a message to those entering the system that permissions are only granted to those authorized by the administrator. To add this message, first open a text editor and /etc/motd. Save the following message (or similar content) to the file and exit:

“This system is restricted to authorized access only. All activities on this system are recorded and logged. Unauthorized access will be fully investigated and reported to the appropriate law enforcement agencies.”

 

Using Secure SSH Logins

For servers running more than one IP, it is important to bind an SSHD to one of the IP addresses and do not use it for any other tasks. This practice will add an additional layer of security to the server.

First, edit /etc/ssh/sshd_config. Next, find the section of code that resembles the following:

#Port 22

#Protocol 2, 1

#ListenAddress 0.0.0.0

#ListenAddress ::

Remove the comment from the Port section and input any other number than 22. Typically a number above 40,000 is best. Also, change Protocol 2, 1 to only Protocol 2. Additionally, when using more than one IP, update the listen address accordingly.

The next step is to disable the root login using SSH. Search for #PermiteRootLogin YES and alter it to read PermitRootLogin NO. Finally, type restart SSHD and confirm functionality.

 

Identifying Nuke PHP Shells

Intruders often add nuke PHP shells to a server for easy access at a later time. To remove suspicious looking files, run the following commands:

locate irc

locate BNC

locate ptlink

locate BitchX

locate guardservices

locate psyBNC

locate eggdrop

locate bnc

locate .rhosts

As a word of caution, this method will often highlight legitimate files. Therefore, be cognizant prior to removing any from the server.

 

Encrypting Data

Encrypting all data is one of the easiest and safest protection methods for any server. This will essentially transform the data leaving and entering the server into an unreadable code. The intruder will only be able to view data as a jumbled mess of computer language.

 

Firewall

The final protective method is to add or enable the firewall on the server. This can usually be accomplished in control panels such as Cpanel. The firewall will block incoming requests and will secure the FTP and eliminate malicious files such with malware and viruses.

1 thought on “Best Practices for Securing a Linux Server”

  1. I have learned new things by means of your site. One other thing I would like to say is the fact newer personal computer os’s are inclined to allow a lot more memory to be used, but they also demand more memory simply to operate. If someone’s computer is unable to handle far more memory as well as the newest computer software requires that storage increase, it is usually the time to shop for a new PC. Thanks

Leave a Comment

Your email address will not be published.

Related Articles

Illustration detailing the relationship between Hivelocity, the cloud, and bare metal
Hivelocity News

Bare Metal Cloud? The Case for Dedicated Server Hardware

As more organizations seek an alternative to the outrageous data egress fees and inherent risks of the cloud, many forward-thinking companies are turning to dedicated server hardware and bare metal clouds as their digital infrastructure solution. With increased processing power, improved reliability, greater customization opportunities, and thousands of dollars in …

Continue read
9/11 in Realtime Header showing an icon of an old MacIntosh computer with the Hivelocity logo
Hivelocity News

Hivelocity Hosts the 9/11 in Realtime Project

September 11th, 2001 is a date which will live in American history forever: a moment frozen in infamy. The 9/11 terrorist attacks were a tragedy which set in motion an era of change throughout the United States and across the global community as a whole. For those of us who …

Continue read