HEX
Server: nginx/1.16.1
System: Linux ecs-04358622 4.19.90-2107.6.0.0100.oe1.bclinux.x86_64 #1 SMP Wed Dec 1 19:59:44 CST 2021 x86_64
User: nginx (994)
PHP: 8.0.0
Disabled: NONE
Upload Files
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