How to set SSH Protocol/ Disable Rool logiin / Not allowing env options / ciphers / client alive intervals etc
#Set SSH Protocal to 2
sed -i 's/Protocol [^ ]*/Protocol 2/g' /etc/ssh/sshd_config
awk '/Protocol 2/{print $0}' /etc/ssh/sshd_config
#Disable SSH root login
sed -i 's/#PermitRootLogin [^ ]*/PermitRootLogin no/g' /etc/ssh/sshd_config
awk '/PermitRootLogin[^ ]*/{print $0}' /etc/ssh/sshd_config
#Set SSH PermitEmptyPassword to No
sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/g' /etc/ssh/sshd_config
awk '/PermitEmptyPasswords[^ ]*/{print $0}' /etc/ssh/sshd_config
#Do NOT Allow Users to Set Environment Options
sed -i 's/#PermitUserEnvironment no/PermitUserEnvironment no/g' /etc/ssh/sshd_config
awk '/PermitUserEnvironment[^ ]*/{print $0}' /etc/ssh/sshd_config
#Use Only Approved Cipher inCounter mode
sed -i '140i\Ciphers aes128-ctr,aes192-ctr,aes256-ctr\' /etc/ssh/sshd_config
awk '/Ciphers aes128-ctr,aes192-ctr,aes256-ctr/{print $0}' /etc/ssh/sshd_config
sleep 5
#Set Idel Timeout Interval for userlogin
sed -i 's/#ClientAliveInterval [^ ]*/ClientAliveInterval 300/g' /etc/ssh/sshd_config
sed -i 's/#ClientAliveCountMax [^ ]*/ClientAliveCountMax 0/g' /etc/ssh/sshd_config
awk '/ClientAliveInterval[^ ]*/{print $0}' /etc/ssh/sshd_config
awk '/ClientAliveCountMax 0[^ ]*/{print $0}' /etc/ssh/sshd_config
sleep 3
service sshd restart
No comments:
Post a Comment