File: //opt/BCLinux/bse/secure_set/s51_sshLogLevel
#!/bin/sh
#=====================================================================
InsertSection "Set the loglevel..."
if [ $SET_SSH_LOGLEVEL -eq 1 ]; then
cp -np /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
#-----------------set the loglevel----------------
IS_EXIST=`egrep -v '^"#"|^$' /etc/ssh/sshd_config | grep 'LogLevel INFO' |wc -l`
if [ ${IS_EXIST} -eq 0 ] ; then
echo " " >> /etc/ssh/sshd_config
echo "LogLevel VERBOSE" >> /etc/ssh/sshd_config
else
sed -i 's/LogLevel INFO/LogLevel VERBOSE/g' /etc/ssh/sshd_config
sed -i 's/^#\(LogLevel[[:space:]]VERBOSE\)/\1/g' /etc/ssh/sshd_config
fi
IS_EXIST=`egrep -v '^#|^$' /etc/ssh/sshd_config | grep '^LogLevel' |wc -l`
if [ ${IS_EXIST} -gt 0 ] ; then
if [[ $(egrep -v '^#|^$' /etc/ssh/sshd_config | grep '^LogLevel' | cut -d ' ' -f 2) != "VERBOSE" ]];then
logtext "set the ssh loglevel failed, wrong setting"
Display --indent 2 --text "- Set the ssh loglevel... " --result FAILED --color RED
else
logtext "set the ssh loglevel successfully"
Display --indent 2 --text "- Set the ssh loglevel... " --result FINISHED --color GREEN
fi
else
#logtext "set the ssh loglevel successfully"
#Display --indent 2 --text "- Set the ssh loglevel... " --result FINISHED --color GREEN
logtext "set the ssh loglevel failed,no set option"
Display --indent 2 --text "- Set the ssh loglevel... " --result FAILED --color RED
fi
#logtext "restart the sshd service..."
#systemctl restart sshd.service
else
Display --indent 2 --text "- Skip set ssh loglevel due to config file... " --result SKIPPING --color YELLOW
fi