20
21
|
I have a project to secure Ubuntu Server as much as I can. The server is a web hosting server. The server will be running LAMP , Mail , and DNS.
| ||||||||
|
29
|
Here is a list of things I do to secure my server.
A few more things to consider. Most people forget about physical access. All the software configurations in the world don't mean anything if I can physically walk in with a LiveCD and steal your data. Beware of social engineering. Ask questions to verify who is on the phone and make sure they have authorization to make the request they are making.
Since I'm still a 'new' user, I can't post more than 2 links. You can read up more about this subject here:https://help.ubuntu.com/12.04/serverguide/index.html and pay special attention tohttps://help.ubuntu.com/12.04/serverguide/security.html
| ||||||||||||||||||||
|
10
+250
|
Since you said this is web-hosting-server... I would like to share my best practices and experience of 5 long years in the web-hosting line.
In the end of the day... work with utter piece of mind, don't get emotional with the install and applying common sense takes you far beyond.
| ||||||||||||||||
|
9
| Secure shared memory
/dev/shm can be used in an attack against a running service, such as httpd. Modify /etc/fstab to make it more secure.
Open a Terminal Window and enter the following :
Add the following line and save. You will need to reboot for this setting to take effect :
Harden network with sysctl settings
The /etc/sysctl.conf file contain all the sysctl settings. Prevent source routing of incoming packets and log malformed IP's enter the following in a terminal window
Edit the /etc/sysctl.conf file and un-comment or add the following lines :
To reload sysctl with the latest changes, enter:
Prevent IP Spoofing
Open a Terminal and enter the following :
Add or edit the following lines :
Harden PHP for security
Edit the php.ini file :
Add or edit the following lines :
Web Application Firewall - ModSecurityProtect from DDOS (Denial of Service) attacks - ModEvasiveScan logs and ban suspicious hosts - DenyHosts and Fail2Ban@DenyHosts
DenyHosts is a python program that automatically blocks SSH attacks by adding entries to /etc/hosts.deny. DenyHosts will also inform Linux administrators about offending hosts, attacked users and suspicious logins.
Open a Terminal and enter the following :
After installation edit the configuration file /etc/denyhosts.conf and change the email, and other settings as required.
To edit the admin email settings open a terminal window and enter:
Change the following values as required on your server :
@ Fail2Ban
Fail2ban is more advanced than DenyHosts as it extends the log monitoring to other services including SSH, Apache, Courier, FTP, and more.
Fail2ban scans log files and bans IPs that show the malicious signs -- too many password failures, seeking for exploits, etc.
Generally Fail2Ban then used to update firewall rules to reject the IP addresses for a specified amount of time, although any arbitrary other action could also be configured. Out of the box Fail2Ban comes with filters for various services (apache, courier, ftp, ssh, etc).
Open a Terminal and enter the following :
After installation edit the configuration file /etc/fail2ban/jail.local and create the filter rules as required.
To edit the settings open a terminal window and enter:
Activate all the services you would like fail2ban to monitor by changing enabled = false to *enabled = true*
For example if you would like to enable the SSH monitoring and banning jail, find the line below and change enabled from false to true. Thats it.
If you would like to receive emails from Fail2Ban if hosts are banned change the following line to your email address.
and change the following line from :
to:
You can also create rule filters for the various services that you would like fail2ban to monitor that is not supplied by default.
Good instructions on how to configure fail2ban and create the various filters can be found onHowtoForge - click here for an example
When done with the configuration of Fail2Ban restart the service with :
You can also check the status with.
Check for rootkits - RKHunter and CHKRootKit.
Both RKHunter and CHKRootkit basically do the same thing - check your system for rootkits. No harm in using both.
Open a Terminal and enter the following :
To run chkrootkit open a terminal window and enter :
To update and run RKHunter. Open a Terminal and enter the following
Scan open ports - Nmap
Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing.
Open a Terminal and enter the following :
Scan your system for open ports with :
SYN scanning with the following :
Analyse system LOG files - LogWatch
Logwatch is a customizable log analysis system. Logwatch parses through your system's logs and creates a report analyzing areas that you specify. Logwatch is easy to use and will work right out of the package on most systems.
Open a Terminal and enter the following :
To view logwatch output use less :
To email a logwatch report for the past 7 days to an email address, enter the following and replace mail@domain.com with the required email. :
Audit your system security - Tiger.
Tiger is a security tool that can be use both as a security audit and intrusion detection system.
Open a Terminal and enter the following :
To run tiger enter :
All Tiger output can be found in the /var/log/tiger
To view the tiger security reports, open a Terminal and enter the following :
| ||||
|
6
|
Make use of the Bastille Linux project.
It provides an interactive tool to perform additional security hardening measures to increase the over-all security, and decrease the susceptibility of compromise for your Ubuntu system (from Bastille Linux).
It offers an assessment and reporting functionality, so that it can tell you what parts of the system aren't locked down. It examines the system in a read-only fashion, reporting on the status of each of its hardening items. For example, Bastille might check whether the DNS server is locked in a chroot prison, whether telnet is turned off, or even if passwords are required to be a good length. You can take a look at a Web-only demo of this through this link (more info).
You can have preview of the Web (only) demo here.
| ||||||||
|
3
|
Use
nmap on all interfaces on the machine, so you know what services you run on your machine. This is an essential tool for security.
Remove all services you don't need on your external interfaces. You can configure MySQL to only listen on specific interfaces, like localhost.
Use ufw to protect your SSH service (and possible others) so that it doesn't allow too many (failed) connections per minute from same machine. That will make brute force attacks harder. To change port number isn't that usefull, just obscurity, no security.
Be restrictive with the number of accounts on your machine. Also don't install more packages/programs than you actually uses. Only install X11-clients, not a X11-server.
Only allow ssh-login to the machine with digital certificates, no password. That will also make brute force attacks hard/impossible.
| |||
2
|
I would also consult the CIS Debian Benchmarks document and it has a significant number of procedures and processes for hardening the operating system that will apply to Ubuntu since it's a derivative of Debian. I would also consult:
|