• 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 957 Times!

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

  • 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

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

  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023
  • What is a Data Mesh? January 25, 2023
  • What is Vehicular Ad-Hoc Network? January 24, 2023
  • Difference Between Panel Light, COB Light, Track Light January 21, 2023

About This Article

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

Source:The Customize Windows, JiMA.in

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