• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Linux Server Security Hardening Commands

By Abhishek Ghosh March 30, 2017 4:07 pm Updated on March 30, 2017

Linux Server Security Hardening Commands

Advertisement

We have many hands on guides on specific softwares with all commands. Most of them needs time and not exactly covered all the issues. Here is a List of Linux Server Security Hardening Commands For the New SSH Users & New Sysadmins. Guide is For Cloud & Virtual Instances. The way to secure a dedicated server or colocation server will be different for various extra ways of access to physical hardware.

Linux Server Security Hardening Commands

 

What to Read Before Running Linux Server Security Hardening Commands

 

Readers must look once at the three part IPTables guides :

  1. IPtables Basics 1
  2. IPtables Basics 2
  3. IPtables Basics 3

 

It is actually difficult to easily get hacked by script kiddie, if you follow those guides. As a general purpose guideline, I have to say that :

Advertisement

---

  1. Install security updates
  2. Update Kernel
  3. Disable root access as SSH user
  4. Use secure passwords
  5. Bind processes to localhost
  6. Implement firewall
  7. Secure various configurations
  8. Limit access
  9. Remotely monitor systems
  10. Regularly backup
  11. Perform system auditing
  12. Separate IPv6 with reverse proxy

 

Linux Server Security Hardening Commands

 

Faillog

We can run faillog command to check records, set login failure limits etc. faillog command reads from the failure log files like /var/log/faillog. Here is manual page of faillog for Ubuntu :

Vim
1
http://manpages.ubuntu.com/manpages/zesty/man8/faillog.8.html

If you run :

Vim
1
faillog -a

You’ll get :

Vim
1
2
3
4
5
6
7
Login       Failures Maximum Latest                   On
 
root         2592        0   01/01/70 05:30:00 +0530
daemon          0        0   01/01/70 05:30:00 +0530
bin             0        0   01/01/70 05:30:00 +0530
sys             0        0   01/01/70 05:30:00 +0530
...

Accounts

We need to make sure that no accounts have empty password and except root no account have UID 0. We can run these two commands :

Vim
1
2
awk -F: '($2 == "") {print}' /etc/shadow
awk -F: '($3 == "0") {print}' /etc/passwd

Under normal condition, only second command will give this output :

Vim
1
root:x:0:0:root:/root:/bin/bash

Check Services and Packages

We can check the services on newer CentOS, Ubuntu with this command :

Vim
1
systemctl list-unit-files --type=service

We can check the installed packages on Ubuntu, Debian with this command.

We can check the running network services :

Vim
1
sudo netstat -tulpn

Other things we actually covered though different previously published article like

  1. List of Essential Security Tools For GNU/Linux Servers
  2. Day to Day Commands for Sysadmins
  3. server logs
  4. tools and commands for brute forcing
  5. checking Fail2Ban log etc.

What we listed in tis guide is usually not used and will work as my self reminder as well. It will be too big article too list all the possible commands. From those linked guides, here is a command to check the auth log for Failed passwords:

Vim
1
cat /var/log/auth.log* | grep 'Failed password' | grep sshd | awk '{print $1,$2}' | sort | uniq -c

Same for gzip files :

Vim
1
zcat /var/log/auth.log* | grep 'Failed password' | grep sshd | awk '{print $1,$2}' | sort | uniq -c

Example output :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
     49 Feb 27
     55 Feb 28
     50 Mar 1
     78 Mar 10
     58 Mar 11
     53 Mar 12
     72 Mar 13
     58 Mar 14
     58 Mar 15
     61 Mar 16
     51 Mar 17
     62 Mar 18
     16 Mar 19
     63 Mar 2
     58 Mar 3
     50 Mar 4
     67 Mar 5
     55 Mar 6
     89 Mar 7
     57 Mar 8
     75 Mar 9

Now there are application specific matters like securing Apache2, Nginx, PHP, MySQL etc. We can protect files with chattr. We can use :

Vim
1
chattr -R +i my-directory

to make it “undeletable”.

Obviously that is possible on files :

Vim
1
chattr +i /etc/my.cnf

If you want to “undo” that undeletable state, you need to use chattr -i command.

Tagged With Computers Internet Child Safety , list of linux server hardware failures

This Article Has Been Shared 471 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Linux Server Security Hardening Commands

  • Optimizing Page Speed of vBulletin for Rackspace Cloud Sites

    Optimizing Page Speed of vBulletin for Rackspace Cloud Sites is hard even by a Page Speed Specialist because not really for Cloud. Still Let us try to optimize.

  • OpenStack Cloud : Now is the Turn of SUSE Linux

    OpenStack Cloud Computing Software can be considered as a cloud infrastructure controller and technically better. SUSE Linux also seems to favor the path.

  • SaaS, Cloud Computing and Mobile : 3 Factors That Changed Many Things

    SaaS, Cloud Computing and Mobile changing the world of webhosting, something that needed to change profoundly. Web is changing by delivery of services online.

  • Cloud Security Tools

    Cloud Security Tools checks the security in cloud environments, there are several tools available for free, users not necessarily have to buy expensive suites.

  • Difference Between cPanel like Control Panel and PaaS

    Difference Between cPanel like Control Panel and PaaS is very minute from practical usage point. There are web hosting plans which are more towards SaaS.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud Computing : Cybersecurity Tips for Small Business Owners January 20, 2021
  • Arduino : Independently Blink Multiple LED January 18, 2021
  • What is a Loosely Coupled System? January 17, 2021
  • How To Repack Installed Software on Debian/Ubuntu January 16, 2021
  • Components of Agile Software Development January 15, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Linux Server Security Hardening Commands," in The Customize Windows, March 30, 2017, January 20, 2021, https://thecustomizewindows.com/2017/03/linux-server-security-hardening-commands/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy