Linux Security Hardening: Disable Root Login, Enforce Password Policies, and More
This guide outlines key Linux security hardening steps, including disabling root password login, enforcing complex password policies with expiration, verifying sudo privileges, shutting down FTP services, setting file ownership and permissions, and managing command history to enhance system protection.
1. Disable root password login
Modify /etc/ssh/sshd_config and set PermitRootLogin to false.
2. Linux user password complexity and expiration
a. Passwords must contain three character types and be longer than 15 characters.
b. Set expiration for manually added user passwords using chage.
View a user's password expiration:
chage -l testSet password expiration: chage -M number-of-days username This uses the -M option to define the maximum number of days before a password expires.
3. Check sudo privileges
The sudo command elevates privileges. Its configuration file is /etc/sudoers. By default only the root user has sudo rights; adding other users is discouraged for security.
4. Disable FTP
Check FTP processes: ps -ef | grep ftp Terminate FTP processes:
kill -9 pid5. Set file ownership and permissions
Change file owner and group: chown -R test:test /opt/test/ Set read/write/execute permissions:
chmod 400 /opt/test/6. Manage command history
Linux command history can be viewed with history, which by default records up to 1000 lines. The limit is configured in /etc/profile and can be set to 20.
After securing the system, clear the history:
echo > $HOME/.bash_historySigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
