2013-08-07 86 views
2

bash腳本所以我寫了一個腳本,可以改變在CentOS SSH端口,但由於某種原因,我遇到這個錯誤:更改SSH端口在CentOS

sshchangecOS6.sh: line 36: syntax error: unexpected end of file

這是腳本:

#! /bin/bash 
# This script changes the ssh port for logins on CentOS 5 and 6 
if [[ $EUID -ne 0 ]]; then 
echo "This script must be run as root" 
    exit 2 
read -r -p "Would you like to change the ssh port? [Y/N] " response 
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] 
then  
    read -p "What would you like to change the port to? (Chose between 1024-65535) " sshportconfig 
    if ((("$sshportconfig" > 1024) && ("$sshportconfig" < 65535))); then 
    echo "Port $sshportconfig" >> /etc/ssh/sshd_config 
    echo "--------------------------------------------------------------------" 
    echo "" 
    echo "" 
    echo "SSH port has been changed to: $sshportconfig. Written by Sincere the Minotaur." 
    echo "" 
    echo "" 
    echo "--------------------------------------------------------------------" 
    else 
    echo "Port chosen is incorrect." 
    exit 1 
    fi 
else 
    sshPort=$(grep "Port" /etc/ssh/sshd_config) | head -n 1 
    echo "--------------------------------------------------------------------" 
    echo "" 
    echo "" 
    echo "SSH is still: $sshPort" 
    echo "Written by Sincere the Minotaur." 
    echo "" 
    echo "---------------------------------------------------------------------" 
    exit 1 
fi 
exit 0 

有人可以解釋錯誤的位置?

回答

1

沒有fi第一個如果if [[ $EUID -ne 0 ]]; then。您需要用fi關閉每個if

+0

謝謝!我知道我錯過了一些東西。 – minossec