Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thost96/faffc29430238e241bdc8656d17cc0bc to your computer and use it in GitHub Desktop.
Save thost96/faffc29430238e241bdc8656d17cc0bc to your computer and use it in GitHub Desktop.
Retrieves the plaintext JNLP for the iKVM console from a SuperMicro IPMI webserver
#!/usr/bin/env bash
# Retrieves the plaintext JNLP from a SuperMicro IPMI webserver
# Usage: supermicro-java-console.sh <hostname>
# supermicro-java-console.sh 10.1.2.34 > login.jnlp
set -x
HOST="$1"
IPMI_USER=${IPMI_USER:-ADMIN}
IPMI_PASS=${IPMI_PASS:-ADMIN}
SESSION_ID=$(curl -s "http://${HOST}/cgi/login.cgi" --data "name=${IPMI_USER}&pwd=${IPMI_PASS}" -i | awk '/SID=[^;]/ { print $2 }')
URL="http://${HOST}/cgi/url_redirect.cgi?url_name=ikvm&url_type=jwsk"
is_mac() {
[[ "$(uname)" == "Darwin" ]]
}
# Some versions of the SuperMicro webserver return a 500 w/o the referer set,
# so we just use http://localhost here.
if is_mac; then
curl -s "${URL}" -H 'Referer: http://localhost' -H "Cookie: ${SESSION_ID}"
else
# The sed is to fix the "no iKVM64 in java.library.path bug on Linux
# Source: http://blog.coffeebeans.at/?p=83
curl -s "${URL}" -H 'Referer: http://localhost' -H "Cookie: ${SESSION_ID}" | sed 's/Linux" arch="a.*/&\n <property name="jnlp.packEnabled" value="true"\/>\n <property name="jnlp.versionEnabled" value="true"\/>/'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment