linux安全--ssh

#!/bin/bash    
#    
read -p "Please enter a normal user used for login ssh servers: " SSHUSER    
                                while true        ;do    
                                                                id $SSHUSER        
                    
                                                                if [ $? -eq 0 ]; then    
                                                                                                read -p "Please enter a normal user used for login ssh servers: " SSHUSER    
                                                                else    
                                                                                                break    
                                                                fi    
                                done    
SSHPASSWD=$(</dev/urandom tr -dc _A-Z-a-z-0-9 | head -c30;echo)    
echo -e "\033[31m Please remember your password $SSHUSER $SSHPASSWD \033[0m"        
useradd $SSHUSER    
echo $SSHPASSWD | passwd --stdin $SSHUSER    
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original    
cat        >> /etc/ssh/sshd_config <<"EOF"    
AllowUsers $SSHUSER    
PermitRootLogin no    
LoginGraceTime 2m    
MaxAuthTries 3    
MaxSessions 5    
IgnoreRhosts yes    
ClientAliveInterval 300s    
ClientAliveCountMax 0      
PermitEmptyPasswords no    
EOF
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章