{"id":5395,"date":"2020-04-12T13:00:53","date_gmt":"2020-04-12T10:00:53","guid":{"rendered":"https:\/\/kifarunix.com\/?p=5395"},"modified":"2021-03-20T21:38:12","modified_gmt":"2021-03-20T18:38:12","slug":"install-and-setup-kolide-fleet-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-kolide-fleet-on-ubuntu-18-04\/","title":{"rendered":"Install and Setup Kolide Fleet on Ubuntu 18.04"},"content":{"rendered":"\n
In this guide, we are going to learn how to install and Setup Kolide Fleet on Ubuntu 18.04. Kolide Fleet<\/a> is an opensource Osquery manager that expand Osquery capabilities from a single machine to your entire fleet. It queries a dynamic sets of hosts and watch the data stream in for immediate analysis and investigation.<\/p>\n\n\n\n Kolide Fleet has retired. Check the new replacement, the Fleetdm Fleet.<\/p>\n\n\n\n Install Fleet Osquery Manager on Ubuntu 20.04<\/a><\/p>\n\n\n\n Resynchronize your system packages to their latest versions.<\/p>\n\n\n\n Kolide Fleet application is distributed as a single static binary which serves the Fleet web interface, the Fleet application API endpoints and the osquery TLS server API endpoints.<\/p>\n\n\n\n To download the latest Kolide Fleet binary, simply execute the command below;<\/p>\n\n\n\n Once the Fleet binary is downloaded, extract the Kolide Fleet binaries for Linux platform.<\/p>\n\n\n\n The command above extracts the Kolide Fleet binaries, the fleet<\/strong> and fleetctl<\/strong> binaries to fleet\/linux<\/strong> directory.<\/p>\n\n\n\n The installation of Kolide Fleet binaries is therefore as easy as copying them to binary directories e.g Kolide Fleet is now installed;<\/p>\n\n\n\n Kolide Fleet requires MySQL\/MariaDB for its database and Redis server for ingesting and queueing the results of distributed queries, cache data, etc.<\/p>\n\n\n\n Create MariaDB 10.4 APT repository<\/p>\n\n\n\n Update your package cache.<\/p>\n\n\n\n Run the command install MariaDB server.<\/p>\n\n\n\n MariaDB server is started and enabled to run on system boot upon installation. You can check the status;<\/p>\n\n\n\n Run the initial MySQL security script, mysql_secure_installation<\/strong>, to remove anonymous database users, test tables, disable remote root login.<\/p>\n\n\n\n By default, MariaDB 10.4 uses unix_socket for authentication by default and hence, can login by just running, Next, create the Kolide database.<\/p>\n\n\n\n Note:<\/strong> the database database names used here are not standard. Choose any name of your preference.<\/strong><\/p>\n\n\n\n Create Kollide Fleet database user with all grants on Kolide DB created above.<\/p>\n\n\n\n Reload privileges tables and exit the database;<\/p>\n\n\n\n Run the command below to install Redis on Ubuntu 18.04.<\/p>\n\n\n\n Redis is set to start and enabled on system boot upon installation.<\/p>\n\n\n\n To initialize Fleet infrastructure after installing and setting up all the requirements above, use the If the initialization is complete, you should get the output,<\/p>\n\n\n\n Fleet serve is used to run the main HTTPS server. Hence, run the command below to generate self-signed certificates.<\/p>\n\n\n\n NOTE: If you are using Self Signed Certificates as in this demo, DO NOT use wildcards or enrollment of hosts won’t work.<\/strong><\/p>\n\n\n\n If you can, use the commercial TLS certificates from your preferred trusted CA.<\/strong><\/p>\n\n\n\n Generate a random To help with auto-generating the token, simply run the fleet server command without this option.<\/p>\n\n\n\n The command fails and auto-generates a random key for you;<\/p>\n\n\n\n Once you get a random key, rerun the command with the option and the key provided. <\/p>\n\n\n\n Kolide Fleet is setup and thus you need to run the command below to verify that it can run successfully using the fleet serve<\/strong> command as shown below.<\/p>\n\n\n\n If all is well, you should see that Fleet server is now running on 0.0.0.0:8080<\/strong> and hence can be accessed on https:\/\/<server-IP>:8080<\/strong>.<\/p>\n\n\n\n Press Ctrl+c to stop Kolide Fleet server.<\/p>\n\n\n\n Once you have verified that Kolide Fleet is running fine, create a systemd service file.<\/p>\n\n\n\n Save and exit the file.<\/p>\n\n\n\n Reload systemd configurations.<\/p>\n\n\n\n Start and enable Kolide Fleet service.<\/p>\n\n\n\n Check the status;<\/p>\n\n\n\n Kolide Fleet can be accessed on the browser using the URL https:\/\/<server-IP_OR_hostname>:8080<\/strong>.<\/p>\n\n\n\n Setup your username, password, email, organization details and proceed to Kollide Web interface.<\/p>\n\n\n\n Next, install osquery on the host servers you want to enroll. We have already covered the installation of osquery on Debian 10 and Ubuntu 18.04 in our previous guide, see the links below;<\/p>\n\n\n\n How to Install Osquery on Ubuntu 18.04<\/a><\/p>\n\n\n\n Install Osquery on Debian 10 Buster<\/a><\/p>\n\n\n\n Once osquery is installed, add your host to Kolide by navigating to Hosts > Add New Hosts<\/strong>.<\/p>\n\n\n\n When you click Add new host<\/strong>, a wizard like in below pops up with the instructions on how to add hosts to fleet instance.<\/p>\n\n\n\n To enroll your osquery hosts, you need the secret key and the TLS certificate. Hence, Copy the secret key and click On the host to enroll to the Kolide Fleet, install the secret key and the certificate as follows;<\/p>\n\n\n\n Copy the TLS certificate to the host being enrolled on Kolide Fleet. Replace host-address with the host IP\/address.<\/p>\n\n\n\n On the host being enrolled, verify the TLS server certificate;<\/p>\n\n\n\n Next, stop the Run osqueryd with the following options on the host being enrolled, replacing the \u2013enroll_secret_path<\/strong> and \u2013tls_server_certs<\/strong> accordingly.<\/p>\n\n\n\n If all goes well, you should see some output similar to;<\/p>\n\n\n\n Your host should now be enrolled on your Kolide Fleet Server.<\/p>\n\n\n\n To run Osquery with the details enrollment details above, edit its service file such that it looks like as in below;<\/p>\n\n\n\n Reload system daemons.<\/p>\n\n\n\n Start osqueryd.<\/p>\n\n\n\n Check status;<\/p>\n\n\n\n Once the hosts are enrolled, you can query them directly from Kolide Fleet.<\/p>\n\n\n\n For example, to query non system users with the query:<\/p>\n\n\n\n Click Query on the left panel > Create new query. Define the Name of the Query, the query itself, Description, the target host.<\/p>\n\n\n\n Click RUN to execute the query. You can save the query if you want.<\/p>\n\n\n\n And Boom!!! You got Kolide Fleet working on Ubuntu 18.04 and is able to query remote hosts running Osquery. That marks the end of your guide on how to install and setup Kolide Fleet on Ubuntu 18.04.<\/p>\n\n\n\n Install Kolide Fleet Osquery Fleet Manager on Debian 10<\/a><\/p>\n\n\n\n Install GLPI ITSM Tool on CentOS 8<\/a><\/p>\n\n\n\nInstall and Setup Kolide Fleet on Ubuntu 18.04<\/h2>\n\n\n\n
Run system update<\/h3>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
Download Kolide Fleet BInary Installer<\/h3>\n\n\n\n
wget https:\/\/github.com\/kolide\/fleet\/releases\/latest\/download\/fleet.zip<\/code><\/pre>\n\n\n\n
Install and Setup Kolide Fleet on Ubuntu 18.04<\/h3>\n\n\n\n
unzip fleet.zip 'linux\/*' -d fleet<\/code><\/pre>\n\n\n\n
ls fleet\/linux\/<\/code><\/pre>\n\n\n\n
fleet<\/strong> fleetctl<\/strong><\/code><\/pre>\n\n\n\n
\/usr\/bin<\/code><\/strong>.<\/p>\n\n\n\n
cp fleet\/linux\/* \/usr\/bin\/<\/code><\/pre>\n\n\n\n
ls \/usr\/bin\/fleet*<\/code><\/pre>\n\n\n\n
\/usr\/bin\/fleet \/usr\/bin\/fleetctl<\/code><\/pre>\n\n\n\n
Install and Setup Kolide Fleet Dependencies on Ubuntu 18.04<\/h3>\n\n\n\n
Install MariaDB 10.4 Database on Ubuntu 18.04<\/h4>\n\n\n\n
apt install software-properties-common<\/code><\/pre>\n\n\n\n
apt-key adv --recv-keys --keyserver hkp:\/\/keyserver.ubuntu.com:80 0xF1656F24C74CD1D8<\/code><\/pre>\n\n\n\n
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http:\/\/sfo1.mirrors.digitalocean.com\/mariadb\/repo\/10.4\/ubuntu bionic main'<\/code><\/pre>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt install mariadb-server mariadb-client<\/code><\/pre>\n\n\n\n
Running MariaDB<\/h4>\n\n\n\n
systemctl status mariadb<\/code><\/pre>\n\n\n\n
systemctl is-enabled mariadb<\/code><\/pre>\n\n\n\n
mysql_secure_installation<\/code><\/pre>\n\n\n\n
Create Kolide Fleet Database and Database User<\/h4>\n\n\n\n
mysql -u root<\/strong><\/code>. If have however enabled password authentication, simply run;<\/p>\n\n\n\n
mysql -u root -p<\/code><\/pre>\n\n\n\n
create database kolide;<\/code><\/pre>\n\n\n\n
grant all on kolide.* to kolideadmin@localhost identified by 'StrongP@SS';<\/code><\/pre>\n\n\n\n
flush privileges;
exit<\/code><\/pre>\n\n\n\nInstall Redis on Ubuntu 18.04<\/h4>\n\n\n\n
apt install redis<\/code><\/pre>\n\n\n\n
Running Kolide Fleet Server on Ubuntu 18.04<\/h3>\n\n\n\n
Initialize Kolide Fleet Database<\/h4>\n\n\n\n
fleet prepare db<\/code> as follows;<\/p>\n\n\n\n
fleet prepare db --mysql_address=127.0.0.1:3306 --mysql_database=kolide --mysql_username=kolideadmin --mysql_password=StrongP@SS<\/code><\/pre>\n\n\n\n
Migrations completed.<\/code><\/pre>\n\n\n\n
Generate SSL\/TLS Certificates<\/h4>\n\n\n\n
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \/etc\/ssl\/private\/kolide.key -out \/etc\/ssl\/certs\/kolide.cert -subj \"\/CN=kolide.kifarunix-demo.com\/\"<\/code><\/pre>\n\n\n\n
Generate Json Web Token<\/h4>\n\n\n\n
Json Web Token (JWT)<\/code> key for signing and verify session tokens. This will be required when running the fleet serve<\/strong> command for use with \u2013auth_jwt_key<\/strong> option. Fleet server won’t start without this option<\/strong>.<\/p>\n\n\n\n
fleet serve --mysql_address=127.0.0.1:3306 \\\n--mysql_database=kolide --mysql_username=kolideadmin --mysql_password=StrongP@SS \\\n--server_cert=\/etc\/ssl\/certs\/kolide.cert --server_key=\/etc\/ssl\/private\/kolide.key \\\n--logging_json<\/code><\/pre>\n\n\n\n
################################################################################\n# ERROR:\n# A value must be supplied for --auth_jwt_key. This value is used to create\n# session tokens for users.\n#\n# Consider using the following randomly generated key:\n# WS+Q2v6RyJdZgJDCHFWgak5HtxzPDhH8<\/strong>\n################################################################################<\/code><\/pre>\n\n\n\n
Testing Kolide Fleet<\/h4>\n\n\n\n
fleet serve --mysql_address=127.0.0.1:3306 \\\n--mysql_database=kolide --mysql_username=kolideadmin --mysql_password=StrongP@SS \\\n--server_cert=\/etc\/ssl\/certs\/kolide.cert --server_key=\/etc\/ssl\/private\/kolide.key \\\n--logging_json --auth_jwt_key=WS+Q2v6RyJdZgJDCHFWgak5HtxzPDhH8<\/strong><\/code><\/pre>\n\n\n\n
{\"component\":\"service\",\"err\":null,\"method\":\"ListUsers\",\"took\":\"921.991\u00b5s\",\"ts\":\"2020-04-12T07:06:41.184166743Z\",\"user\":\"none\"}\n{\"address\":\"0.0.0.0:8080\",\"msg\":\"listening\",\"transport\":\"https\",\"ts\":\"2020-04-12T07:06:41.185827799Z\"}<\/code><\/pre>\n\n\n\n
Create Kolide Fleet Systemd Service Unit on Ubuntu 18.04<\/h3>\n\n\n\n
vim \/etc\/systemd\/system\/kolide-fleet.service<\/code><\/pre>\n\n\n\n
[Unit]\nDescription=Kolide Fleet Osquery Fleet Manager\nAfter=network.target\n\n[Service]\nLimitNOFILE=8192\nExecStart=\/usr\/bin\/fleet serve \\\n --mysql_address=127.0.0.1:3306 \\\n --mysql_database=kolide \\\n --mysql_username=kolideadmin \\\n --mysql_password=StrongP@SS \\\n --redis_address=127.0.0.1:6379 \\\n --server_cert=\/etc\/ssl\/certs\/kolide.cert \\\n --server_key=\/etc\/ssl\/private\/kolide.key \\\n --auth_jwt_key=WS+Q2v6RyJdZgJDCHFWgak5HtxzPDhH8 \\\n --logging_json\nExecStop=\/bin\/kill -15 $(ps aux | grep \"fleet serve\" | grep -v grep | awk '{print$2}')\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl enable --now kolide-fleet<\/code><\/pre>\n\n\n\n
systemctl status kolide-fleet<\/code><\/pre>\n\n\n\n
\u25cf kolide-fleet.service - Kolide Fleet Osquery Fleet Manager\n Loaded: loaded (\/etc\/systemd\/system\/kolide-fleet.service; enabled; vendor preset: enabled)\n Active: active (running) since Sun 2020-04-12 10:23:44 EAT; 3s ago\n Main PID: 6777 (fleet)\n Tasks: 6 (limit: 1108)\n CGroup: \/system.slice\/kolide-fleet.service\n \u2514\u25006777 \/usr\/bin\/fleet serve --mysql_address=127.0.0.1:3306 --mysql_database=kolide --mysql_username=kolideadmin --mysql_password=StrongP@SS \n\nApr 12 10:23:44 u18 systemd[1]: Started Kolide Fleet Osquery Fleet Manager.\nApr 12 10:23:44 u18 fleet[6777]: {\"component\":\"service\",\"err\":null,\"method\":\"ListUsers\",\"took\":\"218.912\u00b5s\",\"ts\":\"2020-04-12T07:23:44.414494933Z\",\"user\"\nApr 12 10:23:44 u18 fleet[6777]: {\"address\":\"0.0.0.0:8080\",\"msg\":\"listening\",\"transport\":\"https\",\"ts\":\"2020-04-12T07:23:44.418368662Z\"}<\/code><\/pre>\n\n\n\n
Access Kolide Fleet Web Interface<\/h3>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure><\/li><\/ul><\/figure>\n\n\n\n
Adding New Hosts to Kolide Fleet<\/h3>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Fetch Fleet Certificate<\/code><\/strong> to download.<\/p>\n\n\n\n
echo \"qzAJao+jKVsoZi6Ck1OgheS5VPhfqPRc\" > \/var\/osquery\/secret<\/code><\/pre>\n\n\n\n
scp kolide.kifarunix-demo.com_8080.pem koromicha@host-address<\/strong>:kolide.kifarunix-demo.com.pem<\/code><\/pre>\n\n\n\n
sudo cp kolide.kifarunix-demo.com.pem \/var\/osquery\/<\/code><\/pre>\n\n\n\n
openssl s_client -connect kolide.kifarunix-demo.com:8080 -CAfile \/var\/osquery\/kolide.kifarunix-demo.com.pem<\/code><\/pre>\n\n\n\n
---\nSSL handshake has read 1353 bytes and written 391 bytes\nVerification: OK<\/strong>\n---<\/code><\/pre>\n\n\n\n
osqueryd<\/strong><\/code> if it is running;<\/p>\n\n\n\n
systemctl stop osqueryd<\/code><\/pre>\n\n\n\n
\/usr\/bin\/osqueryd --enroll_secret_path=\/var\/osquery\/secret \\\n--tls_server_certs=\/var\/osquery\/kolide.kifarunix-demo.com.pem \\\n--tls_hostname=kolide.kifarunix-demo.com:8080 \\\n--host_identifier=uuid \\\n--enroll_tls_endpoint=\/api\/v1\/osquery\/enroll \\\n--config_plugin=tls \\\n--config_tls_endpoint=\/api\/v1\/osquery\/config \\\n--config_refresh=10 \\\n--disable_distributed=false \\\n--distributed_plugin=tls \\\n--distributed_interval=3 \\\n--distributed_tls_max_attempts=3 \\\n--distributed_tls_read_endpoint=\/api\/v1\/osquery\/distributed\/read \\\n--distributed_tls_write_endpoint=\/api\/v1\/osquery\/distributed\/write \\\n--logger_plugin=tls \\\n--logger_tls_endpoint=\/api\/v1\/osquery\/log \\\n--logger_tls_period=10<\/code><\/pre>\n\n\n\n
I0412 12:13:40.467630 15162 events.cpp:863] Event publisher not enabled: auditeventpublisher: Publisher disabled via configuration\nI0412 12:13:40.467813 15162 events.cpp:863] Event publisher not enabled: syslog: Publisher disabled via configuration\nI0412 12:13:40.498387 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_network_interface: select ia.interface, address, mask, broadcast, point_to_point,\n id.interface, mac, id.type, mtu, metric, ipackets, opackets,\n ibytes, obytes, ierrors, oerrors, idrops, odrops, last_change\n from interface_details id join interface_addresses ia\n on ia.interface = id.interface where length(mac) > 0\n order by (ibytes + obytes) desc\nI0412 12:13:40.501811 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_os_version: select * from os_version limit 1\nI0412 12:13:40.503866 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_osquery_flags: select name, value from osquery_flags where name in (\"distributed_interval\", \"config_tls_refresh\", \"config_refresh\", \"logger_tls_period\")\nI0412 12:13:40.506964 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_osquery_info: select * from osquery_info limit 1\nI0412 12:13:40.509542 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_system_info: select * from system_info limit 1\nI0412 12:13:40.518357 15175 distributed.cpp:117] Executing distributed query: kolide_detail_query_uptime: select * from uptime limit 1\nI0412 12:13:40.522809 15175 distributed.cpp:117] Executing distributed query: kolide_label_query_6: select 1;\nI0412 12:13:40.526031 15175 distributed.cpp:117] Executing distributed query: kolide_label_query_8: select 1 from os_version where platform = 'ubuntu';\nI0412 12:13:40.528300 15175 distributed.cpp:117] Executing distributed query: kolide_label_query_9: select 1 from os_version where platform = 'centos' or name like '%centos%'<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
vim \/etc\/systemd\/system\/osqueryd.service<\/code><\/pre>\n\n\n\n
[Unit]\nDescription=The osquery Daemon\nAfter=network.service syslog.service\n\n[Service]\nTimeoutStartSec=0\nEnvironmentFile=\/etc\/default\/osqueryd\nExecStartPre=\/bin\/sh -c \"if [ ! -f $FLAG_FILE ]; then touch $FLAG_FILE; fi\"\nExecStartPre=\/bin\/sh -c \"if [ -f $LOCAL_PIDFILE ]; then mv $LOCAL_PIDFILE $PIDFILE; fi\"\nExecStart=\/usr\/bin\/osqueryd \\\n --flagfile $FLAG_FILE \\\n --config_path $CONFIG_FILE \\\n --enroll_secret_path=\/var\/osquery\/secret \\\n --tls_server_certs=\/var\/osquery\/server.pem \\\n --tls_hostname=kolide.kifarunix-demo.com:8080 \\\n --host_identifier=uuid \\\n --enroll_tls_endpoint=\/api\/v1\/osquery\/enroll \\\n --config_plugin=tls \\\n --config_tls_endpoint=\/api\/v1\/osquery\/config \\\n --config_refresh=10 \\\n --disable_distributed=false \\\n --distributed_plugin=tls \\\n --distributed_interval=3 \\\n --distributed_tls_max_attempts=3 \\\n --distributed_tls_read_endpoint=\/api\/v1\/osquery\/distributed\/read \\\n --distributed_tls_write_endpoint=\/api\/v1\/osquery\/distributed\/write \\\n -logger_plugin=tls \\\n --logger_tls_endpoint=\/api\/v1\/osquery\/log \\\n --logger_tls_period=10\nRestart=on-failure\nKillMode=process\nKillSignal=SIGTERM\n\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\n
systemctl start osqueryd<\/code><\/pre>\n\n\n\n
systemctl status osqueryd<\/code><\/pre>\n\n\n\n
\u25cf osqueryd.service - The osquery Daemon\n Loaded: loaded (\/etc\/systemd\/system\/osqueryd.service; disabled; vendor preset: enabled)\n Active: active (running) since Sun 2020-04-12 12:31:14 EAT; 9s ago\n Process: 15281 ExecStartPre=\/bin\/sh -c if [ -f $LOCAL_PIDFILE ]; then mv $LOCAL_PIDFILE $PIDFILE; fi (code=exited, status=0\/SUCCESS)\n Process: 15279 ExecStartPre=\/bin\/sh -c if [ ! -f $FLAG_FILE ]; then touch $FLAG_FILE; fi (code=exited, status=0\/SUCCESS)\n Main PID: 15282 (osqueryd)\n Tasks: 18 (limit: 2315)\n CGroup: \/system.slice\/osqueryd.service\n \u251c\u250015282 \/usr\/bin\/osqueryd --flagfile \/etc\/osquery\/osquery.flags --config_path \/etc\/osquery\/osquery.conf --enroll_secret_path=\/var\/osquery\/se\n \u2514\u250015284 \/usr\/bin\/osqueryd\n...<\/code><\/pre>\n\n\n\n
Querying Host from Kolide Fleet Osquery Manager<\/h3>\n\n\n\n
select username,directory,uid,gid,shell from users where uid >= 1000;<\/strong><\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Related Tutorials<\/h3>\n\n\n\n