• 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

  • How to Add Auto Anchor to WordPress HeadingsJune 7, 2023
  • Self-Hosted Fonts vs. Cloud-Hosted FontsJune 7, 2023
  • How to Restrict Certain Posts or Categories In WordPress by CountryJune 6, 2023
  • Influence of Digitization on Procurement : Part 1June 6, 2023
  • How We Can Show Apple Icon, Windows Logo on Website TextJune 5, 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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT