osquery+kolide fleet安装

 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出现如下图的界面:

复制下面的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的安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值