From 09915b4969d30964b871609a1c682a446b991960 Mon Sep 17 00:00:00 2001 From: jgaunt Date: Tue, 20 Aug 2019 18:23:58 -0400 Subject: [PATCH] Update 'zabbix_agent.sh' --- zabbix_agent.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/zabbix_agent.sh b/zabbix_agent.sh index 12bde78..89e5cb9 100644 --- a/zabbix_agent.sh +++ b/zabbix_agent.sh @@ -46,12 +46,29 @@ fi # ask for the hostname read -e -p "Enter Hostname: " -i "$(cat /etc/hostname)" hostname -sed --in-place "s/^Hostname=Zabbix\ server/Hostname=${hostname}/" /etc/zabbix/zabbix_agentd.conf +# configure the hostname +sed --in-place 's/^Hostname=Zabbix\ server/Hostname='${hostname}'/' /etc/zabbix/zabbix_agentd.conf +# configure the zabbix server +sed --in-place 's/^Server=127.0.0.1/Server='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf +# configure the zabbix server +sed --in-place 's/^ServerActive=127.0.0.1/ServerActive='${ZABBIX_SERVER}'/' /etc/zabbix/zabbix_agentd.conf +# configure the encryption +sed --in-place $'s/^# TLSAccept=unencrypted/# TLSAccept=unencrypted\\\n&TLSAccept=psk/' /etc/zabbix/zabbix_agentd.conf +sed --in-place $'s/^# TLSConnect=unencrypted/# TLSConnect=unencrypted\\\n&TLSConnect=psk/' /etc/zabbix/zabbix_agentd.conf +PSKID=$(openssl rand -hex 8) +sed --in-place $'s/^# TLSPSKIdentity=/# TLSPSKIdentity=\\\n&# TLSPSKIdentity='${PSKID}'/' /etc/zabbix/zabbix_agentd.conf +# generate psk +TLSPSK=$(openssl rand -hex 32 | tee /etc/zabbix/zabbix_agentd.psk) +sed --in-place $'s/^# TLSPSKFile=/# TLSPSKFile=\\\nTLSPSKFile=\/etc\/zabbix\/zabbix_agentd.psk/' /etc/zabbix/zabbix_agentd.conf -sed --in-place "s/^Server=127.0.0.1/Server=${ZABBIX_SERVER}/" /etc/zabbix/zabbix_agentd.conf - -sed --in-place "s/^ServerActive=127.0.0.1/ServerActive=${ZABBIX_SERVER}/" /etc/zabbix/zabbix_agentd.conf systemctl restart zabbix-agent -systemctl enable zabbix-agent \ No newline at end of file +systemctl enable zabbix-agent + +echo "############################################################" +echo "## Encryption Details ##" +echo "## Please enter the PSK ID and PSK into the Zabbix Server ##" +echo "############################################################" +echo "PSK Identity = ${PSKID}" +echo "PSK = ${TLSPSK}" \ No newline at end of file