For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

VladT's avatar
VladT
Icon for Nimbostratus rankNimbostratus
Feb 27, 2023

External monitor for SFTP

Hello F5 Community,

I am trying to set up an external monitor for SFTP and i need some help to make it work.
For authentication i specified the path for the private key.
I am trying to run the sftp with -b option and specifing the path for the command i want to run after authentication.
In the cmd file i added the version command.

May I ask you to have a look and advise what i am missing here in order to make it work?


#!/bin/sh
# these arguments supplied automatically for all external pingers:
# $1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
# $2 = port (decimal, host byte order)
# $3 and higher = additional arguments
#
# $MONITOR_NAME = name of the monitor

 


# Remove the IPv6/IPv4 compatibility prefix
IP=`echo $1 | sed 's/::ffff://'`

 

user="TF5M5412"


# Name of the pidfile
pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"


# Send signal to the process group to kill our former self and any children
# as external monitors are run with SIGHUP blocked
if [ -f $pidfile ]
then
kill -9 -`cat $pidfile` > /dev/null 2>&1
fi

echo "$$" > $pidfile


output=$(sftp -i /config/filestore/files_d/Common_d/certificate_key_d/:Common:SFTP-TEST-unprotected_66821_1 -o StrictHostKeyChecking=no -b /config/filestore/files_d/Common_d/certificate_key_d/cmd $user@$IP)


if echo "$output" | grep -q "version 3"; then
echo "UP"
fi

rm -f "${pidfile}"




2 Replies

  • Can you run this command manually and share the output?

  • VladT's avatar
    VladT
    Icon for Nimbostratus rankNimbostratus

    Helllo,
    Found the issue.
    When trying to run the script manually, noticed this error : bad interpreter: No such file or directory
    Used this command < sed -i -e 's/\r$//'>  to remove the DOS line endings from Text files and the external monitor is working now

    Thank you very much
    Wish you a nice day