SHARE
TWEET

iLO login check script

a guest Jan 14th, 2013 434 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. if [ $# -eq 0 ]
  4. then
  5.         echo "No arguments supplied. Expecting a file with a list of ILO-IPs/DNS names to connect to. E.g. run ./ilocheck.sh /tmp/ilo-list"
  6.         exit 1
  7. fi
  8.  
  9. echo "Enter FULL AD-Account DN (required for ILO1/2) or local account name: (EX: CN=adminuser,OU=departmen1,OU=top,DC=domain,DC=local)"
  10. read -e userdn
  11. userdn64=$( echo -n $userdn | base64 -w 0 )
  12. echo "Enter password:"
  13. read -es pw
  14. pw64=$( echo -n $pw | base64 -w 0 )
  15.  
  16. cat $@ | sort | while read ilo
  17. do
  18.         ilourl="https://$ilo"
  19.         echo -e "\nChecking ILO Interface on $ilourl..."
  20.         curl -ks "$ilourl" | if grep -Pq "HP Integrated Lights-Out( 2)? Login"
  21.         then
  22.                 echo "$ilourl is an ILO2 or ILO1 System"
  23.                 curl -ks "$ilourl/login.htm" | grep -A1 "sessionkey=" | grep -Po '\w[^\"]+' > /tmp/ilotemp
  24.                 sessionkey=$( awk 'FNR == 2 {print}' /tmp/ilotemp )
  25.                 sessionindex=$( awk 'FNR == 4 {print}' /tmp/ilotemp )
  26.                 curl -ks "$ilourl/index.htm" --header "Cookie: hp-iLO-Login=$sessionindex:$userdn64:$pw64:$sessionkey" --header "Referer: $ilourl/login.htm" | if grep -q "has detected a failed login attempt"
  27.                 then
  28.                         echo "Login on $ilourl NOT successful."
  29.                 else
  30.                         echo "Login on $ilourl successful."
  31.                 fi
  32.  
  33.         else
  34.                 curl -ks "$ilourl" | if grep -Pq "iLO [34]"
  35.                 then
  36.                         echo "$ilourl is an ILO3 or ILO4 System"
  37.                         curl -ks "$ilourl/json/login_session" -X POST --data "{\"method\":\"login\",\"user_login\":\"$userdn\",\"password\":\"$pw\"}" | if grep -q "JS_ERR_NO_PRIV"
  38.                         then
  39.                                 echo "Login on $ilourl NOT successful."
  40.                         else
  41.                                 echo "Login on $ilourl successful."
  42.                         fi
  43.                 else
  44.                         echo "ILO Interface of $ilourl unreachable or not found"
  45.                 fi
  46.         fi
  47. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top