File: //opt/BCLinux/bse/secure_set/s13_sshProtocol
#!/bin/sh
#=======================================================
InsertSection "set ssh Protocol"
if [ $SET_SSH_PROTOCOL -eq 1 ]; then
cp -np /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
IS_EXIST=`egrep -v '^#|^$' /etc/ssh/sshd_config | grep 'Protocol' | wc -l`
if [ ${IS_EXIST} -eq 0 ] ; then
echo " " >> /etc/ssh/sshd_config
echo "Protocol 2" >> /etc/ssh/sshd_config
else
sed -i 's/^Protocol.*/Protocol 2/' /etc/ssh/sshd_config
fi
IS_EXIST=`egrep -v '^#|^$' /etc/ssh/sshd_config | grep 'Protocol' | wc -l`
if [ ${IS_EXIST} -eq 0 ] ; then
logtext "No ssh protocol set, set failed"
Display --indent 2 --text "- No ssh protocol config set... " --result FAILED --color RED
#AddHP 0 1
else
if [ $(egrep -v '^#|^$' /etc/ssh/sshd_config | grep 'Protocol' | grep 2 | wc -l) -eq 0 ];then
logtext "Wrong ssh protocol set, checking failed"
Display --indent 2 --text "- Wrong ssh protocol config set... " --result FAILED --color RED
#AddHP 0 1
else
logtext "Set the ssh protocol, checking ok"
Display --indent 2 --text "- Set the ssh protocol... " --result FINISHED --color GREEN
#AddHP 1 1
fi
fi
#logtext "restart the sshd service..."
#systemctl restart sshd.service
else
Display --indent 2 --text "- Skip set ssh protocol due to config file... " --result SKIPPING --color YELLOW
fi