funcionando

master
fanta 2 years ago
parent 3738c31d73
commit 7b4780ef70

@ -1,9 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
fileSSHConnections="/tmp/.sshActualConnections"
logDir="/tmp/"
main(){ main(){
checkRoot checkRoot
haveProgram strace wget lsof haveProgram strace wget lsof awk
printActualSSHConnections printActualSSHConnections
monitoringSocket
} }
checkRoot(){ checkRoot(){
@ -15,7 +19,17 @@ haveProgram(){
} }
printActualSSHConnections(){ printActualSSHConnections(){
lsof -c ssh 2>/dev/null | grep IPv4 | awk '{ print $2,$9 }' | cat -n | tee $tmpFileSSHConnections lsof -c ssh 2>/dev/null | grep IPv4 | awk '{ print $2,$9 }' | cat -n | tee $fileSSHConnections
}
monitoringSocket(){
if [ $(wc -l $fileSSHConnections | cut -d " " -f 1) != 0 ];then
read -p "Enter option number: " nOption
pidSSH=$(cat $fileSSHConnections | awk '{ print $2 }' | head -n $nOption | tail -n 1)
strace -p $pidSSH | tee -a $logDir/sshMonitor-$pidSSH.log
else
echo "No ssh connection found"
fi
} }
main main

Loading…
Cancel
Save