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的安装

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Vim编辑完如何保存退出

    Vim编辑完如何保存退出编辑完按Esc退出编辑模式此时输入::wq保存后退出:wq!强制保存后退出:w保存但不退出:w!若文件属性为只读时,强制写入该文档:q不保存并退出:q!不保存并强制退出…

    2022年8月24日
    4
  • Lambda架构和Kappa架构

    Lambda架构和Kappa架构 数据系统架构——Lambdaarchitecture(Lambda架构)传统系统的问题“我们正在从IT时代走向DT时代(数据时代)。IT和DT之间,不仅仅是技术的变革,更是思想意识的变革,IT主要是为自我服务,用来更好地自我控制和管理,DT则是激活生产力,让别人活得比你好”——阿里巴巴董事局主席马云。数据量从M的…

    2022年6月25日
    26
  • js保留两位小数四舍五入_parsefloat保留两位小数

    js保留两位小数四舍五入_parsefloat保留两位小数一、我们首先从经典的“四舍五入”算法讲起1、四舍五入的情况 1 2 varnum=2.446242342; num=num.toFixed(2);//输出结果为2.45 2、不四舍五入第一种,先把小数边整数: 1 Math.floor(15.7784514000*100)/100//输出结果为15.77 第二种,当作字符串,使用正则匹配: 1

    2022年8月10日
    96
  • spring helloworld

    spring helloworld

    2021年12月9日
    46
  • 【1-100】RadioGroup实现应用主界面「建议收藏」

    【1-100】RadioGroup实现应用主界面

    2022年2月21日
    48
  • nginx默认安装80端口修改[通俗易懂]

    nginx默认安装80端口修改[通俗易懂]nginx默认安装80端口修改nginx默认安装80端口修改nginx默认安装80端口修改nginx安装启动发现80默认端口冲突,一般是和tomcat服务冲突了。所以在这里我们直接取修改nginx的默认端口。通过whereisnginx我们知道了nginx的配置文件目录在配置文件目录下的sites-available目录中我们找到了default文件,进行修改,修改前先备份。vi进去后将80端口修改成8888端口号修改后重启nginx,启动后没有报错。改对应映射nginx.co

    2022年9月4日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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