服务器初始化脚本

服务器初始化脚本

#!/bin/bash
function check_sshd_config(){
    ##1. check PasswordAuthentication
    if [ `grep PasswordAuthentication /etc/ssh/sshd_config 2> /dev/null | grep -v "#" | grep -i no | wc -l` -gt 0 ];then
       echo "#ssh_password_authentication=1" 
    else
       echo "#ssh_password_authentication=0"
    fi

    ##2. check PermitRootLogin
    if [ `grep PermitRootLogin /etc/ssh/sshd_config 2> /dev/null | grep -v "#" | grep -iE "no|prohibit-password" | wc -l` -gt 0 ];then
       echo "#ssh_permit_root_login=1"
    else
       echo "#ssh_permit_root_login=0"
    fi
   
    ##3.check ssh_host_rsa_key permission
    if [ `stat /etc/ssh/ssh_host_rsa_key  | grep Uid | grep -vE "600|100|200|300|400|500|600|700" | wc -l` -gt 0 ];then
       echo "#ssh_ssh_host_rsa_key=1"
    else
       echo "#ssh_ssh_host_rsa_key=0&#

猜你喜欢

转载自blog.csdn.net/hackermmm/article/details/127561969