osquery+kolide fleet安装[通俗易懂]

osquery+kolide fleet安装[通俗易懂]osquery是用于记录本机的一些系统信息,如passwd文件的改变,用户的增加等,有了它,我们可以在系统发生改变后,能够及时查询出来。curl-Lhttps://pkg.osquery.io/rpm/GPG|tee/etc/pki/rpm-gpg/RPM-GPG-KEY-osqueryyum-config-manager–add-repohttps://pkg.osqu…

大家好,又见面了,我是你们的朋友全栈君。

 osquery是用于记录本机的一些系统信息,如passwd文件的改变,用户的增加等,有了它,我们可以在系统发生改变后,能够及时查询出来。

curl -L https://pkg.osquery.io/rpm/GPG | tee /etc/pki/rpm-gpg/RPM-GPG-KEY-osquery
yum-config-manager --add-repo https://pkg.osquery.io/rpm/osquery-s3-rpm.repo
yum-config-manager --enable osquery-s3-rpm
yum install osquery -y
cp /usr/share/osquery/osquery.example.conf /etc/osquery/osquery.conf

osquery有两种运行模式:

一种是交互式运行:osqueryi

还有一种是后台进程模式:osqueryd

osquery存储日志的文件路径:/var/log/osquery/

osqueryd.INFO:保存了主机差异变化信息

osqueryd.results.log

osqueryd.snapshots.log:每次查询的结果记录

osquery的配置文件基础解析:osquery配置文件分为三打段

options:osquery daemon的一些配置,日志产生路径,线程数等。

schedule:设置定时任务

packs:osquery的规则配置

osquery默认有些规则,但是有时候也需要新增规则,下面是一个实用规则的地址,可以参考:

https://github.com/grayddq/HIDS

这个git仓库中,有个secrety.conf文件,该文件是系统主机的监控文件,可以放在/etc/osquery目录下,

修改osquery.conf文件,在packs下增加一行:

“secrity”: “/etc/osquery/secrity.conf”

然后重启osquery服务:systemctl restart osqueryd

kolide fleet安装

首先安装mysql:

wget https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
yum update
yum install -y mysql-community-server.x86_64 mysql-community-client.x86_64 -y
cat /var/log/mysqld.log    //读取mysql的初始化密码
mysql -uroot -pinit_password
//修改root密码
mysql > alter user "root"@"localhost" identified by "Root123...";   
mysql > flush privileges;
mysql > create database kolide;
mysql > exit

安装redis

注:此处安装只为了测试,为了安全,切勿在生成环境如此安装
wget http://download.redis.io/redis-stable.tar.gz
yum install -y gcc g++
tar -zxvf redis-stable.tar.gz && cd redis-stable
make && make install
cp redis.conf /etc/redis.conf
sed -i 's/daemonize no/daemonize yes/' /etc/redis.conf
redis-server /etc/redis.conf

安装fleet

从github上下载fleet.zip文件,

下载地址为:https://github.com/kolide/fleet/releases

下载fleet.zip后,解压:unzip fleet.zip

cp fleet/linux/fleet /usr/bin/fleet

cp fleet/linux/fleetctl /usr/bin/fleetctl

连接数据库:

/usr/bin/fleet prepare db --mysql_address=127.0.0.1:3306 --mysql_database=kolide --mysql_username=root --mysql_password=password

接下来配置证书
openssl genrsa -out /etc/pki/tls/private/server.key 4096
openssl req -new -key /etc/pki/tls/private/server.key -out /etc/pki/tls/certs/server.csr
openssl x509 -req -days 3650 -in /etc/pki/tls/certs/server.csr -signkey /etc/pki/tls/private/server.key -out /etc/pki/tls/certs/server.cert
创建日志目录:
mkdir /var/log/kolide

启动服务
/usr/bin/fleet serve \
    --mysql_address=127.0.0.1:3306 \
    --mysql_database=kolide \
    --mysql_username=root \
    --mysql_password=password \
    --redis_address=127.0.0.1:6379 \
    --server_cert=/etc/pki/tls/certs/server.cert \
    --server_key=/etc/pki/tls/private/server.key \
    --logging_json \
    --osquery_result_log_file=/var/log/kolide/osquery_result \
    --osquery_status_log_file=/var/log/kolide/osquery_status

在第一次执行上面的命令后,会让我们使用参数--auth_jwt_key进行认证,并给出一串key,
然后再上面的命令最后,加上这个参数,并附上key

/usr/bin/fleet serve \
    --mysql_address=127.0.0.1:3306 \
    --mysql_database=kolide \
    --mysql_username=root \
    --mysql_password=password \
    --redis_address=127.0.0.1:6379 \
    --server_cert=/etc/pki/tls/certs/server.cert \
    --server_key=/etc/pki/tls/private/server.key \
    --logging_json \
    --osquery_result_log_file=/var/log/kolide/osquery_result \
    --osquery_status_log_file=/var/log/kolide/osquery_status \
    --auth_jwt_key=your_key

在启动后,查看8080端口是否起来

然后通过https://IP:8080登陆,注意,这里必须使用https进行登陆

登陆了fleet后,进行密码初始化,初始化完成后,开始添加主机:

点击右上角的add new host出现如下图的界面:

osquery+kolide fleet安装[通俗易懂]

复制下面的enroll secret

在主机上执行:echo ‘your enroll secret’ > /var/osquery/enroll_secret

接下来,点击fetch fleet certificate,下载证书:

下载后,执行:mv yourCertificate.pem /var/osquery/server.pem

然后再重新执行osqueryd

/usr/bin/osqueryd \
    --enroll_secret_path=/var/osquery/enroll_secret \
    --tls_server_certs=/var/osquery/server.pem \
    --tls_hostname=YourServerIP:8080 \
    --host_identifier=hostname \
    --enroll_tls_endpoint=/api/v1/osquery/enroll \
    --config_plugin=tls \
    --config_tls_endpoint=/api/v1/osquery/config \
    --config_tls_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

执行完后,刷新页面,可以看到有主机添加,

上面就是osquery+kolide fleet的安装

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/131271.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号