جارى التحميل
  • Public-Key Authentication Script Version 2

    تم عمل بعض التعديلات على السكريبت Public-Key Authentication Script حيث أصبح يدعم قائمة من العناوين مع عمل بعض التعديلات السريعة عليه
    ملاحظة: قمت بإعداد هذا السكريبت بشكل سريع بسبب حاجتي له في العمل فأرجو من كل من وجد أي مشكلة أن يخبرني
    أعتذر عن الانقطاع الطويل و اللذي لم ينتهي بعد لكني قد كتبت السكريبت من فتره و لم أضعه لهذا أحببت أن أضعه لعله ينفع أحد إما باستخدامه أو أن يستفيد من أي شئ في الكود



    #!/bin/bash
    clear
    echo "                                          # ############################################### #"
    echo "                                          #                                                 #"
    echo "                                          #      SSH  Auth. for Single/Multi Machine(s)     #"
    echo "                                          # ----------------------------------------------- #"
    echo "                                          # Author : Eng.Sabri                              #"
    echo "                                          # Created in : Sat Aug 8 2009  02:10 pm           #"
    echo "                                          # Last Modify: Tus Jan 25 2011  10:40 am          #"
    echo "                                          # ############################################### #"
    COLORIZING()
    {
    # Text color variables
    txtund=$(tput sgr 0 1)    # Underline
    txtbld=$(tput bold)       # Bold
    txtred=$(tput setaf 1)    # Red
    txtgrn=$(tput setaf 2)    # Green
    txtylw=$(tput setaf 3)    # Yellow
    txtblu=$(tput setaf 4)    # Blue
    txtpur=$(tput setaf 5)    # Purple
    txtcyn=$(tput setaf 6)    # Cyan
    txtwht=$(tput setaf 7)    # White
    txtrst=$(tput sgr0)       # Text reset

    # Colored Texts
    echo -$(tput sgr0# Reset All Colors
    }

    function 
    message {
    COLORIZING
    if [ $WELCOME ]
    then
    echo  Hello $(logname)
    echo 
    ""
    sleep 1
    else
    echo 
    "no welcome msg for you :P"
    fi
    }

    function 
    INFORMATIONS {
    COLORIZING

    read 
    -" [+] Pleas Enter your Local Host User Name: " LUSER
    read 
    -" [+] Pleas Enter your Remote Host User Name witch you need to Connetc: " RUSER
    echo -$(tput setaf 1)
    echo 
    "#---------------------------#"
    echo "Notic:If you've list of IP's"
    echo "  Put the IP's in text file"
    echo "  Each IP in New Line!"
    echo "  No Empty Lines!"
    echo "  No Spaces!"
    echo "#---------------------------#"
    echo -$(tput sgr0)
    read -" [+] Pleas Enter Remote Host's IP address or IP's List File path : " IPADDR
    read 
    -" [+] Pleas Enter SSH's port used on Remote Host: " RPORT

    # Review
    clear
    echo -$(tput setaf 2)
    echo    
    "=---------------------="
    echo    " Information Review.. "
    echo    "=---------------------="
    echo " [+] Local Host User Name Is.."   $LUSER
    echo " [+] Remote Host User Name Is.."  $RUSER
    echo " [+] Remote Host(s) IP/List Is.." $IPADDR
    echo " [+] Remote Host User Port Is.."  $RPORT
    echo -$(tput sgr0)
    read -" [!] Is this information correct [y or n]? " INFO

    while [ $INFO "n" ]
    do
    clear
    echo    " "
    echo    "=-----------------------------------="
    echo    " Please, Re-Enter Your Information.. "
    echo    "=-----------------------------------="
    echo    " "
    read -" [+] Pleas Enter your Local Host User Name: " LUSER
    read 
    -" [+] Pleas Enter your Remote Host User Name witch you need to Connect: " RUSER
    read 
    -" [+] Pleas Enter Remote Host's IP address or IP's List File path: " IPADDR
    read 
    -" [+] Pleas Enter SSH's port used on Remote Host: " RPORT
    # Review
    clear
    echo -$(tput setaf 2)
    echo    
    "=---------------------="
    echo    " Information Review.. "
    echo    "=---------------------="
    echo " [+] Local Host User Name Is.."   $LUSER
    echo " [+] Remote Host User Name Is.."  $RUSER
    echo " [+] Remote Host(s) IP/List Is.." $IPADDR
    echo " [+] Remote Host User Port Is.."  $RPORT
    echo -$(tput sgr0)
    read -" [!] Is this information correct [y or n]? " INFO
    done
    sleep 1
    }

    function 
    PKG {
    COLORIZING
    # Encryption
    read -" [+] Pleas Chose the Encryption Type [rsa , des] " ENC
    ssh
    -keygen -t $ENC

    # Check is it List Of IP's or Just One IP
    if [ -f $IPADDR ]
    then

    for LIST in $(cat $IPADDR)
    do
    if [ 
    $USER 'root' ]; then
    scp 
    -P $RPORT /root/.ssh/id_rsa.pub $RUSER@$LIST:.ssh/authorized_keys
    #       exit 0

    else
    scp -P $RPORT /home/$LUSER/.ssh/id_rsa.pub $RUSER@$LIST:.ssh/authorized_keys
    fi
    done

    else
    if [ 
    $USER 'root' ]; then
    scp 
    -P $RPORT /root/.ssh/id_rsa.pub $RUSER@$IPADDR:.ssh/authorized_keys
    exit 0

    else

    scp -P $RPORT /home/$LUSER/.ssh/id_rsa.pub $RUSER@$IPADDR:.ssh/authorized_keys
    fi
    fi
    }

    INFORMATIONS
    PKG

    echo -$(tput setaf 6)
    echo 
    " "
    echo "--------------------------------------"
    echo " Regards & Respect Good Bye $(logname)"
    echo "--------------------------------------"
    echo -$(tput sgr0)
    sleep 3
    exit 
    تحياتي واحترامي
    This article was originally published in forum thread: Public-Key Authentication Script Version 2 started by KING SABRI View original post