From 3738c31d738d260f785756f5fed5c3245505a638 Mon Sep 17 00:00:00 2001 From: fanta Date: Wed, 2 Feb 2022 17:51:24 +0100 Subject: [PATCH] primeras funciones --- sshMonitor.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 sshMonitor.sh diff --git a/sshMonitor.sh b/sshMonitor.sh new file mode 100755 index 0000000..9f1704c --- /dev/null +++ b/sshMonitor.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +main(){ + checkRoot + haveProgram strace wget lsof + printActualSSHConnections +} + +checkRoot(){ + if [ "$(whoami)" != "root" ]; then echo -e "\e[31m\e[1m[NOT OK]\e[0m Run it with root please" && exit ; fi +} + +haveProgram(){ + for i in $@; do type $i &> /dev/null ; if [ $? == 1 ]; then echo "$i not found. Please install it"; fi ; done +} + +printActualSSHConnections(){ + lsof -c ssh 2>/dev/null | grep IPv4 | awk '{ print $2,$9 }' | cat -n | tee $tmpFileSSHConnections +} + +main