VirtualBox 中 Ubuntu 的安全设置清单
一 系统与账户安全
sudo apt update && sudo apt full-upgrade -y && sudo reboot,及时修补内核与组件漏洞。sudo apt install unattended-upgrades -y && sudo dpkg-reconfigure --priority=low unattended-upgrades,选择“是”以自动安装安全更新。last -x | headsudo apt install fail2ban -y,复制默认配置 sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local,在 [sshd] 段启用并适度设置 bantime、maxretry,重启服务 sudo systemctl restart fail2ban。systemctl list-unit-files --type=service | grep enabled,对不必要服务执行 sudo systemctl disable --now 服务名;ss -tulpen | grep LISTEN,仅保留必需端口。二 网络与 VirtualBox 配置
dhcp4: true 改为 dhcp4: nosudo netplan apply三 防火墙与端口管理
sudo apt install ufw -ysudo ufw default deny incoming、sudo ufw default allow outgoingsudo ufw allow 2222/tcpsudo ufw allow 80/tcp、sudo ufw allow 443/tcpsudo ufw enable、sudo ufw status verbose四 SSH 安全加固
/etc/ssh/sshd_config:
PermitRootLogin noPasswordAuthentication noPubkeyAuthentication yessudo systemctl restart sshAllowUsers youruser。Port 2222,并同步更新防火墙与端口转发规则。sudo ufw allow from 192.168.56.0/24 to any port 2222 proto tcp五 存储 备份与最小攻击面
rsync/borgbackup)。sudo apt install rsyslog logrotate -y,确保 /var/log 分区充足,定期审计 auth.log、syslog。ss -tulpensudo systemctl list-timers --all、crontab -l -u root