Home

About Us

Advertisement

Contact Us

PRIVACY POLICY

  • Facebook
  • X
  • Instagram
  • Pinterest
  • WhatsApp
  • RSS Feed
  • TikTok
ALT

Maalavs Blog

Your Trusted Voice Across the World.

  • NEWS
  • Linux Tech Blogs
  • Windows Tech Blogs
  • VIRTUALIZATION Blogs
Search

šŸ” Linux Security and Hardening Guide šŸ–„ļø

Author: Madhan Gopalakrishnan | Published on : 13-02-2025

Linux security is crucial for protecting systems from unauthorized access, malware, and cyber threats. Hardening a Linux system involves implementing security measures to reduce vulnerabilities. This guide provides an easy-to-understand yet in-depth explanation of Linux security and system hardening techniques. šŸš€


šŸ›”ļø Basic Security Concepts

šŸ›  Security AspectšŸ” Description
AuthenticationVerifies user identity using passwords, SSH keys, or multi-factor authentication (MFA).
AuthorizationGrants or restricts access based on user roles and permissions.
EncryptionProtects data by converting it into an unreadable format.
FirewallsFilters network traffic to allow or block access based on security rules.
Updates & PatchingRegularly updating the system to fix security vulnerabilities.

šŸ”‘ User and Access Management

šŸ›  CommandšŸ” DescriptionšŸ“Œ Syntax
whoShows currently logged-in userswho
wDisplays active users and their processesw
idShows user ID (UID) and group ID (GID)id [username]
groupsLists groups a user belongs togroups [username]
passwdChanges the user passwordpasswd [username]
usermodModifies an existing userusermod -aG [group] [username]
chmodChanges file permissionschmod [permissions] [file]
chownChanges file ownershipchown [user]:[group] [file]

Best Practices:

  • Use strong passwords and enable password expiration policies.
  • Implement multi-factor authentication (MFA).
  • Limit the use of the root account; use sudo instead.

šŸ”„ Firewall & Network Security

šŸš€ Firewall Configuration (UFW, IPTables, Firewalld)

šŸ›  CommandšŸ” DescriptionšŸ“Œ Syntax
ufw enableEnables UFW firewallsudo ufw enable
ufw allow 22Allows SSH accesssudo ufw allow 22
iptables -LLists active firewall rulessudo iptables -L
firewalldManages firewall rules dynamicallysudo firewall-cmd --state

Best Practices:

  • Restrict open ports and allow only necessary services.
  • Implement fail2ban to prevent brute-force attacks.
  • Use VPNs for secure remote access.

šŸ›‘ Secure SSH Configuration

šŸ›  Security MeasurešŸ” Command
Disable root loginEdit /etc/ssh/sshd_config, set PermitRootLogin no
Change SSH portModify Port 22 to a custom port in sshd_config
Use key-based authenticationssh-keygen & ssh-copy-id user@server
Enable Fail2Bansudo apt install fail2ban & configure /etc/fail2ban/jail.conf

šŸ›  System Hardening Techniques

šŸ›  TechniquešŸ” Description
Disable Unused ServicesUse systemctl disable [service] to stop unnecessary services.
Enable Automatic UpdatesConfigure unattended-upgrades for automatic security patches.
Check System LogsUse journalctl -xe and /var/log/syslog to analyze system logs.
AppArmor/SELinuxUse AppArmor or SELinux for additional process restrictions.
Enable Auditingauditctl & ausearch for monitoring security-related events.

šŸ” Intrusion Detection & Monitoring

šŸ›  ToolšŸ” Description
chkrootkitChecks for rootkits in the system.
rkhunterScans for known vulnerabilities.
lynisPerforms a security audit and hardening recommendations.
tripwireMonitors system file integrity.

šŸš€ Conclusion

Linux security and hardening are ongoing processes that require continuous monitoring and updates. By implementing these techniques, you can safeguard your system against potential threats. šŸ›”ļøšŸ§

āœ… Best Practices and Next Steps:

  1. Regularly audit and update your security settings:
    • Use lynis audit system to scan for security weaknesses.
    • Update all packages using sudo apt update && sudo apt upgrade.
    • Review user accounts with sudo cat /etc/passwd.
    • Remove unnecessary software and disable unused services.
    • Schedule periodic security audits and penetration testing.
  2. Implement log monitoring and alerting systems:
    • Use journalctl, syslog, and dmesg for analyzing logs.
    • Install log monitoring tools like Nagios, Zabbix, or ELK Stack.
    • Set up automatic alerts for suspicious activities with auditd.
    • Use fail2ban to monitor failed login attempts and block attackers.
  3. Explore advanced security frameworks like SELinux and AppArmor:
    • SELinux: Enforce access controls beyond standard user permissions.
    • AppArmor: Restricts applications based on predefined security profiles.
    • Enable SELinux using sudo setenforce 1 and check status with sestatus.
    • Enable AppArmor using sudo aa-enforce /etc/apparmor.d/*.
    • Configure security policies with semanage and aa-complain.
  4. Enhance Security with Additional Measures:
    • Encrypt sensitive files using gpg -c file or openssl enc.
    • Set up a host-based intrusion detection system (HIDS) like OSSEC.
    • Implement security event logging with rsyslog.
    • Secure physical access by setting BIOS/bootloader passwords.

Happy Securing! šŸ”’šŸš€

šŸ”—Other Topics Links Related to Linux Security and Log Monitoring

  • šŸ” Linux Security Hardening: Implementing Email Alert Systems šŸ“§šŸš€
  • šŸ” Linux Security Hardening: Implementing Log Monitoring and Alerting Systems šŸ›”ļø
  • šŸ” Linux Security Hardening: SELinux & Semanage šŸ–„ļø
  • šŸ” Linux Security Hardening: Capturing User Activity Logs šŸ“ŠšŸ“”

Featured Articles

  • Insights into Royal Family Dynamics

    Insights into Royal Family Dynamics

    February 26, 2025
  • Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    February 26, 2025
  • North Korea Accused of Major Cyber Heist

    North Korea Accused of Major Cyber Heist

    February 26, 2025
  • Manchester United Announces Job Cuts Amid Financial Restructuring

    Manchester United Announces Job Cuts Amid Financial Restructuring

    February 26, 2025
  • Shannon Sharpe Criticizes Zion Williamson’s Fitness: A Deep Dive into the Controversy

    Shannon Sharpe Criticizes Zion Williamson’s Fitness: A Deep Dive into the Controversy

    February 26, 2025

Search

Author Details

Madhan Gopalakrishnan

I am a passionate “tech blogger” with a knack for breaking down complex topics into simple insights or exploring the latest trends in AI With 5 years of experience in IT Infra implementation and maintenance, I love to share knowledge through in-depth articles and practical tips. When not writing, you can find my hobby “traveling to offbeat destinations”.

  • X
  • Instagram
  • TikTok
  • Facebook

Follow Us on

  • Facebook
  • X
  • Instagram
  • VK
  • Pinterest
  • Last.fm
  • TikTok
  • Telegram
  • WhatsApp
  • RSS Feed

Categories

  • Article (15)
  • NEWS (73)

Archives

  • February 2025 (88)

Tags

About Us

Maalavs Magazine

It is your hub for the latest news across all domains, from technology and business to travel and innovation. We bring insightful updates, expert opinions, and engaging content to keep you informed and ahead. Whether you’re a tech enthusiast, a business professional, or a curious reader, we’ve got something for you. Stay updated with Maalavs Magazine!

Latest Articles

  • Insights into Royal Family Dynamics

    Insights into Royal Family Dynamics

    February 26, 2025
  • Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    Over 50 Deaths Linked to ‘Unknown Disease’ in Congo

    February 26, 2025
  • North Korea Accused of Major Cyber Heist

    North Korea Accused of Major Cyber Heist

    February 26, 2025

Categories

  • Article (15)
  • NEWS (73)
  • Instagram
  • Facebook
  • LinkedIn
  • X
  • VK
  • TikTok

Proudly Powered by Maalavs | Maalavs Magazine

Scroll to Top