1. 系统更新与补丁管理1.1 定期更新保持Ubuntu系统的软件和系统本身定期更新是确保安全的基础。这可以通过启用自动更新功能来实现,确保在第一时间修复已知漏洞。sudo apt update su...
保持Ubuntu系统的软件和系统本身定期更新是确保安全的基础。这可以通过启用自动更新功能来实现,确保在第一时间修复已知漏洞。
sudo apt update
sudo apt upgrade使用unattended-upgrades包,可以设置系统在后台自动安装安全更新。
sudo apt install unattended-upgrades配置UFW(Uncomplicated Firewall)来限制对系统的访问,只允许必要的端口和服务,如SSH和HTTP。
sudo ufw allow OpenSSH
sudo ufw allow http禁用root登录,使用密钥认证代替密码认证,并更改SSH默认端口。
sudo sed -i 's/^PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
sudo sed -i 's/^#Port 22/Port 2222/' /etc/ssh/sshd_config
sudo systemctl restart sshd避免使用root账户进行日常操作,使用普通用户账户,并根据需要为用户授予必要的权限。
sudo passwd -l root通过修改/etc/pam.d/common-password文件,可以设置强密码策略。
sudo sed -i 's/^password requisite pam_pwquality.so retry=3 minlen=8 difok=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1/match minlen=8 difok=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1/' /etc/pam.d/common-password为虚拟机设置合适的网络模式,必要时进行网络隔离,减少攻击面。
sudo ufw disable
sudo ufw default deny incoming
sudo ufw default allow outgoing禁用任何未使用的网络服务以最大限度地减少攻击面。
sudo systemctl stop cups
sudo systemctl disable cups使用auditd和syslog等工具监控系统和应用程序的日志,及时发现并解决潜在的安全问题。
sudo apt install auditd
sudo auditctl -w /etc/passwd -p warx -k passwd_modification定期进行系统和应用程序的安全审计,及时发现并解决潜在的安全问题。
sudo apt install logwatch
sudo logwatch通过以上五大实用技巧,您可以轻松提升Ubuntu系统的安全性,守护您的数据安全。