#!/bin/bash
# Script to modifty the Protocol value in /etc/ssh/sshd_config 

if [ "$1" == "query" ]; then
   protocol=`grep "Protocol" /etc/ssh/sshd_config | cut -d" " -f2`
   rc=$?
   printf $protocol
   exit $rc
fi

if [ "$1" == "all" ]; then
   /usr/bin/sed -e '/Protocol/d' /etc/ssh/sshd_config > /etc/ssh/sshd_config.tmp
   mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config
   echo "Protocol 2,1" >> /etc/ssh/sshd_config
else
   /usr/bin/sed -e '/Protocol/d' /etc/ssh/sshd_config > /etc/ssh/sshd_config.tmp
   mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config
   echo "Protocol $1" >> /etc/ssh/sshd_config
fi
exit 0
