是否可以列出系统上不属于包的每个文件?或者如果它们已被修改?
可能需要使用类似的东西:apt-get、apt-files、dpkg-query 等
对于上下文,想象一下继承一个无法格式化的旧服务器,并且您想检查每个文件是否应该是这样......我知道在 Debian 版本之间升级或删除后不会出现这种情况一个没有“--purge”的包,因为它似乎留下了很多(通常是配置)文件。
同样,如果要用新服务器替换该服务器,您需要确保所有配置差异(与基本安装相比)都已转移(如果不再相关,则将其忽略 - 例如添加了胭脂“端口”行到 sshd_config)。
它还有助于确定是否在不使用 apt-get 的情况下安装了任何东西。
您刚刚获得了一个新的 HTTPS (SSL/TLS) 证书,您希望得到正确的中间证书。
这是在 Apache 中设置的:
SSLCertificateKeyFile /etc/ssl/www.example.com.key
SSLCertificateChainFile /etc/ssl/www.example.com.chn
SSLCertificateFile /etc/ssl/www.example.com.crt
Run Code Online (Sandbox Code Playgroud)
或者在 Nginx 中使用:
ssl_certificate_key /etc/apache2/ssl/www.example.com.key;
ssl_certificate /etc/apache2/ssl/www.example.com.pem;
Run Code Online (Sandbox Code Playgroud)
记住apachectl configtest
只检查这些文件是否存在;并且nginx -t
“如果网站证书不是 crt 文件中的第一个,并且密钥错误,则会失败”(感谢Drifter104)。
那么,如何在重新启动之前检查所有内容?
您有错误的中间体(例如,GeoTrust 在一页上列出了它们的所有中间体)。
您不小心将中间证书文件与您的网站证书文件混合在一起。
您包含了根证书(影响性能,因为这会发送不必要的数据)。
您缺少一个或多个中级证书。
证书用于错误的密钥。
您已将这些文件保留为服务器上的任何人都可以读取(例如chmod 644
)。
提取有关密钥、CSR 或证书文件的信息:
openssl rsa -check -in "www.example.com.key";
openssl req -text -noout -verify -in "www.example.com.csr";
openssl x509 -text -noout -in "www.example.com.crt";
Run Code Online (Sandbox Code Playgroud)
使用 sha256 获取公钥哈希(例如用于设置 HPKP):
openssl rsa …
Run Code Online (Sandbox Code Playgroud) 使用目录结构:
/www/live/website1/app/
/www/live/website1/files/
/www/live/website1/logs/
Run Code Online (Sandbox Code Playgroud)
Apache 至少需要以下访问权限:
app: read-only access, but read-write is fine (files already chmod 0644)
files: read-write access
logs: read-write access
Run Code Online (Sandbox Code Playgroud)
通过以下方式设置了以下两个规则:
/usr/sbin/semanage fcontext -a -t httpd_sys_content_t "/www/live/.*/.*";
/usr/sbin/semanage fcontext -a -t httpd_log_t "/www/live/.*/logs(/.*)?";
/sbin/restorecon -vr "/www";
Run Code Online (Sandbox Code Playgroud)
应用了哪些,并且似乎工作正常……但是 LogRotate 并不满意。
LogRotate 配置当前为:
/www/live/*/logs/*access_log /www/live/*/logs/*access_log_443 {
weekly
rotate 52
missingok
notifempty
nodateext
sharedscripts
postrotate
/usr/sbin/apachectl graceful > /dev/null
endscript
}
Run Code Online (Sandbox Code Playgroud)
然而,这似乎被 SELinux 阻止,当它试图点击与/www/live
文件夹相关的 inode (在下面的示例中为 262146)时,条目出现在 audit.log 中......因为它可能试图列出 /www 中的文件夹/居住/。
type=AVC msg=audit(1396579563.324:316060): avc: denied { read } …
Run Code Online (Sandbox Code Playgroud)