Windows Server部署osqueryd对接Kolide Fleet,服务运行无上报及flag配置适配问题求助
Windows Server环境osquery对接Kolide Fleet节点不显示的配置调整指导
问题场景
在Windows Server环境部署osquery并对接Kolide Fleet平台时,已成功完成osqueryd系统服务创建并执行启动命令,但Kolide Fleet管理仪表盘未显示任何该节点的接入信息,当前不清楚如何调整flag参数适配Windows系统服务的运行要求。
已记录的现存操作与配置
原执行的服务创建命令
sc.exe create osqueryd type= own start= auto error= normal binpath= "C:\Program Files\osquery\osqueryd\osqueryd.exe --flagfile=\Program Files\osquery\osquery.flags" displayname= 'osqueryd' sc.exe start osqueryd
原osquery.flags配置内容
--enroll_secret_path="C:\Users\xxx\Desktop\Secret\enroll_secret.txt" --tls_server_certs="C:\Users\xxx\Desktop\Secret\certiticate.cer" --tls_hostname=127.0.0.1:8080 --host_identifier=uuid --enroll_tls_endpoint=/api/v1/osquery/enroll --config_plugin=tls --config_tls_endpoint=/api/v1/osquery/config --config_refresh=10 --disable_distributed=false --distributed_plugin=tls --distributed_interval=3 --distributed_tls_max_attempts=3 --distributed_tls_read_endpoint=/api/v1/osquery/distributed/read --distributed_tls_write_endpoint=/api/v1/osquery/distributed/write --logger_plugin=tls --logger_tls_endpoint=/api/v1/osquery/log --logger_tls_period=10
适配Windows系统服务的核心调整项
osquery在Windows上以系统服务运行时,是以LocalSystem账号身份启动的,工作目录默认指向C:\Windows\System32,和手动双击启动osqueryd的运行环境有显著差异,现有配置存在多处导致连接失败的问题,需按以下内容修正:
- 修正路径类配置的权限与兼容性问题
- 原配置中
enroll_secret_path、tls_server_certs指向普通用户桌面路径,LocalSystem账号无权限读取该路径下的文件,需将两个文件迁移到osquery安装目录下(如C:\Program Files\osquery\certs\),并为LocalSystem账号分配读取权限。 - 修正证书文件名拼写错误:原配置中写的
certiticate.cer为拼写偏差,需和实际保存的证书文件名完全一致,避免osquery因找不到证书文件终止TLS连接。 - 原服务创建命令中flagfile使用
\Program Files\osquery\osquery.flags这种相对根盘的路径,在System账号工作目录下会解析异常,需改为全绝对路径C:\Program Files\osquery\osquery.flags。
- 原配置中
- 修正TLS连接的校验配置
tls_hostname配置的值需和Kolide Fleet服务端TLS证书中定义的主题备用名称(SAN)完全匹配,否则会触发证书校验失败。如果为本地自签证书且通过IP连接,需确保证书SAN字段包含对应IP地址。- 临时追加调试类flag,方便快速定位连接问题:
--verbose=1、--tls_dump=1,启动服务后查看osquery日志可直接看到和Fleet平台的交互报错原因。
- 补充日志路径的权限适配
原配置未显式指定本地日志路径,osquery默认会在LocalSystem账号的用户目录C:\Windows\System32\config\systemprofile\osquery\下写入日志,需确保对应目录有写入权限;也可显式追加flag指定日志路径到osquery安装目录下,避免权限问题:--logger_path=C:\Program Files\osquery\log\osqueryd.results.log。
调整后的参考配置
删除原有已创建的osqueryd服务,按修正后的内容重新执行创建命令、修改flag配置:
修正后的服务创建命令
sc.exe create osqueryd type= own start= auto error= normal binpath= "C:\Program Files\osquery\osqueryd\osqueryd.exe --flagfile=C:\Program Files\osquery\osquery.flags" displayname= "osqueryd" sc.exe start osqueryd
修正后的osquery.flags参考配置
--enroll_secret_path="C:\Program Files\osquery\certs\enroll_secret.txt" --tls_server_certs="C:\Program Files\osquery\certs\certificate.cer" --tls_hostname=127.0.0.1:8080 --host_identifier=uuid --enroll_tls_endpoint=/api/v1/osquery/enroll --config_plugin=tls --config_tls_endpoint=/api/v1/osquery/config --config_refresh=10 --disable_distributed=false --distributed_plugin=tls --distributed_interval=3 --distributed_tls_max_attempts=3 --distributed_tls_read_endpoint=/api/v1/osquery/distributed/read --distributed_tls_write_endpoint=/api/v1/osquery/distributed/write --logger_plugin=tls --logger_tls_endpoint=/api/v1/osquery/log --logger_tls_period=10 --verbose=1 --logger_path=C:\Program Files\osquery\log\osqueryd.results.log
内容的提问来源于stack exchange,提问作者IamNewbie
相关产品推荐
相关产品推荐

