• 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
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, 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

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Command Prompt Commands : Alphabetical list of all commands in Windows 7

    Command Prompt Commands in Windows 7 provides the user access to 180+ command line commands. Here is a list of 200 Command Prompt Commands in Windows 7.

  • awk Command : Examples for SSH

    Here are Some awk Command Examples for SSH, Possibly the Most Commonly Used Command Line Interface for Many of the Webmasters and Developers.

  • Join/Merge Multiple Log Files For Big Data Analysis

    Here Are The Ways To Join/Merge Multiple Log Files For Big Data Analysis, Store Them To OpenStack Based Cloud Storage And Delete Old Files.

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

Get new posts by email:

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 (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Affiliate Marketing Condition/Commission ModelsNovember 28, 2023
  • How Affiliate Marketing WorksNovember 28, 2023
  • Phases of Product DevelopmentNovember 27, 2023
  • Sub-Areas of Direct MarketingNovember 27, 2023
  • Strengths and Weakness of Direct MarketingNovember 26, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

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

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