OpenSSL在Debian中的最佳实践
sudo apt update && sudo apt install openssl libssl-dev
./config shared zlib(启用共享库和zlib压缩)、make -j$(nproc)(并行编译加速)、sudo make install,最后更新动态链接库缓存:sudo ldconfig。sudo apt update && sudo apt upgrade openssl
unattended-upgrades工具,实现后台自动下载和安装安全更新。sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
openssl version确认当前版本,确保使用最新的稳定版(如3.x系列)。/etc/ssl/openssl.cnf)或服务配置中,禁用SSL 2.0/3.0等老旧协议,仅启用TLS 1.2及以上版本。ECDHE-RSA-AES256-GCM-SHA384等支持前向保密(PFS)的算法,避免MD5、SHA-1等弱哈希算法。server {
listen 443 ssl;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
# 其他配置...
}
ufw工具仅开放必要端口(如SSH的22/tcp、HTTPS的443/tcp),拒绝其他未授权访问。sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw deny 80/tcp # 若无需HTTP,直接封锁
/etc/ssh/sshd_config中的PermitRootLogin no),使用SSH密钥对认证(替代密码登录),降低暴力破解风险。openssl genpkey -algorithm RSA -out private.key -aes256
openssl req -new -key private.key -out csr.csr # 填写域名、组织等信息
openssl x509 -req -days 365 -in csr.csr -signkey private.key -out certificate.crt
openssl x509 -in certificate.crt -text -noout
openssl.cnf)备份至安全位置(如加密存储设备),防止丢失或泄露。/var/log/syslog、/var/log/nginx/access.log)。fail2ban等工具监控异常登录尝试(如多次失败的SSH登录),自动封禁恶意IP。lynis、OpenVAS等工具进行系统安全扫描,检查OpenSSL配置是否符合安全规范(如是否禁用不安全协议、是否使用强加密套件)。