java Supermirco IPMI KVM:无需浏览器的远程连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26160165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Supermirco IPMI KVM: remote connection without webbrowser
提问by Stock
I try to connect with the IPMI remote connection(KVM) without the use op the webbrowser or IPMIview tool. But so far no luck.
我尝试与 IPMI 远程连接 (KVM) 连接,而不使用 webbrowser 或 IPMIview 工具。但到目前为止还没有运气。
The first think that I did is launching the "jviewer.jnlp" with javaws. This file will be created by the IPMI website if you push the "Remote Connection" button. This solution works until the web session is closed. I try to replace the encrypted argument with the username and password. But somehow there is session id embedded.
我做的第一个想法是使用 javaws 启动“jviewer.jnlp”。如果您按下“远程连接”按钮,IPMI 网站将创建此文件。此解决方案在 Web 会话关闭之前一直有效。我尝试用用户名和密码替换加密的参数。但不知何故嵌入了会话ID。
jviewer.jnpl file:
jviewer.jnpl 文件:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="https://192.168.99.201/Java">
<information>
<title>JViewer</title>
<vendor>American Megatrends, Inc.</vendor>
<description kind="one-line">JViewer Console Redirection Application</description>
<description kind="tooltip">JViewer Console Redirection Application</description>
<description kind="short">
JViewer enables a user to view the video display of managed server via KVM.
It also enables the user to redirect his local keyboard, mouse for managing the server remotely.
</description>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+"/>
<jar href="release/JViewer.jar"/>
</resources>
<resources os="Windows" arch="x86">
<j2se version="1.5+"/>
<nativelib href="release/Win32.jar"/>
</resources>
<resources os="Windows" arch="amd64">
<j2se version="1.5+"/>
<nativelib href="release/Win64.jar"/>
</resources>
<resources os="Linux" arch="x86">
<j2se version="1.5+"/>
<nativelib href="release/Linux_x86_32.jar"/>
</resources>
<resources os="Linux" arch="i386">
<j2se version="1.5+"/>
<nativelib href="release/Linux_x86_32.jar"/>
</resources>
<resources os="Linux" arch="x86_64">
<j2se version="1.5+"/>
<nativelib href="release/Linux_x86_64.jar"/>
</resources>
<resources os="Linux" arch="amd64">
<j2se version="1.5+"/>
<nativelib href="release/Linux_x86_64.jar"/>
</resources>
<resources os="Mac OS X" arch="i386">
<j2se version="1.5+"/>
<nativelib href="release/Mac32.jar"/>
</resources>
<application-desc>
<argument>192.168.99.201</argument>
<argument>5901</argument>
<argument>Hnda9A159AwMjwnF</argument>
<argument>0</argument>
<argument>0</argument>
<argument>5120</argument>
<argument>5123</argument>
<argument>511</argument>
<argument>5900</argument>
<argument>1</argument>
<argument>EN</argument>
<argument>HEWKovXQO2Fp7FEMho6LrM4kzTPFHPyB000</argument>
</application-desc>
</jnlp>
The argument username and password replacement will work if the jnlp is named as "launch.jnlp" Some Supermicro IPMI version will use a different structure.
如果 jnlp 被命名为“launch.jnlp”,则用户名和密码替换参数将起作用,某些 Supermicro IPMI 版本将使用不同的结构。
Second I try to connect with the IPMIview tool version 2.9.32. That work so the connection is ok. Know I try the connect by using the jars of the IPMIview. Replace the host with the IPMI IP
其次,我尝试连接 IPMIview 工具版本 2.9.32。那工作所以连接没问题。知道我使用 IPMIview 的 jars 尝试连接。用 IPMI IP 替换主机
java -Djava.library.path=. -jar iKVM.jar host ADMIN ADMIN null 5900 2623 2 0
This will open the remote connection but gives a "Connection failed" error.
这将打开远程连接,但会出现“连接失败”错误。
java -Djava.library.path=. -jar JViewerX9.jar host ADMIN ADMIN
Also the same result: Connection failed The connection failed comes with a warning box. On OK is closed the application
同样的结果:连接失败 连接失败带有警告框。在 OK 上关闭应用程序
Some IPMI info:
一些 IPMI 信息:
# ipmitool mc info
Device ID : 32
Device Revision : 1
Firmware Revision : 2.4
IPMI Version : 2.0
Manufacturer ID : 47488
Manufacturer Name : Unknown (0xB980)
Product ID : 43707 (0xaabb)
Product Name : Unknown (0xAABB)
Device Available : yes
Provides Device SDRs : no
Additional Device Support :
Sensor Device
SDR Repository Device
SEL Device
FRU Inventory Device
IPMB Event Receiver
IPMB Event Generator
Chassis Device
Aux Firmware Rev Info :
0x01
0x00
0x00
0x00
A cold reset "ipmitool mc reset cold" also does not work.
冷重置“ipmitool mc reset Cold”也不起作用。
I hope that someone knows what the argument mean for the jnlp file or the someone has a working solution for this problem
我希望有人知道 jnlp 文件的参数意味着什么,或者有人对此问题有一个可行的解决方案
Edit: I try the answer of Maxim Akristiniy and came up with the following code:
编辑:我尝试了 Maxim Akristiniy 的答案并想出了以下代码:
package com.thalesgroup.nl.perftools;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.List;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
import com.gargoylesoftware.htmlunit.util.Cookie;
public class IpmiRemoteViewer {
public static void main(String[] args)
throws FailingHttpStatusCodeException, MalformedURLException,
IOException {
String username = "ADMIN";
String password = "ADMIN";
String ip = "192.168.99.150";
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getCookieManager().addCookie(
new Cookie(ip, "WEBVAR_USERNAME", username));
webClient.getCookieManager().addCookie(
new Cookie(ip, "WEBVAR_PASSWORD", password));
HtmlPage page1 = webClient.getPage("http://" + ip);
List<HtmlForm> forms = page1.getForms();
if (!forms.isEmpty()) {
HtmlForm form = forms.get(0);
HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue(
"Login").get(0);
// username
HtmlTextInput textField = form.getInputByName("T1");
textField.setValueAttribute(username);
// password
HtmlPasswordInput textField2 = form.getInputByName("T2");
textField2.setValueAttribute(password);
HtmlPage page2 = button.click();
webClient.waitForBackgroundJavaScript(500);
// Do it again
form = page2.getForms().get(0);
// username
textField = form.getInputByName("T1");
textField.setValueAttribute(username);
// password
textField2 = form.getInputByName("T2");
textField2.setValueAttribute(password);
ScriptResult scriptResult = page2.executeJavaScript("DoLogin();");
// Print the index.html page
System.out.println(scriptResult.getNewPage().toString());
// Print the session id
for (Cookie cookie : webClient.getCookieManager().getCookies()) {
if (cookie.getName().equals("SessionCookie")) {
String sessionId = cookie.getValue();
System.out.println("Session id = " + sessionId);
}
}
// Download the jviewer.jnlp file
Page page5 = webClient.getPage("http://" + ip
+ "/Java/jviewer.jnlp?EXTRNIP=" + ip + "&JNLPSTR=JViewer");
WebResponse response = page5.getWebResponse();
InputStream inputStream = response.getContentAsStream();
writeToFile("viewer.jnlp", inputStream);
}
}
protected static void writeToFile(String filename, InputStream inputStream) {
OutputStream outputStream = null;
try {
File file = new File(filename);
// write the inputStream to a FileOutputStream
outputStream = new FileOutputStream(file);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Only now it will write the login page in the viewer.jnlp file. Still no luck. I managed to read the index.html page that is behind the login page. But the session is closing very fast.
只有现在它才会在viewer.jnlp 文件中写入登录页面。仍然没有运气。我设法阅读了登录页面后面的 index.html 页面。但是会议结束得非常快。
回答by Stock
Download the jviewer.jnlp file but first login.
下载 jviewer.jnlp 文件但首先登录。
#!/bin/sh
USER=ADMIN
PASS=ADMIN
HOST=192.168.99.150
COOKIE=`curl --data "WEBVAR_USERNAME=$USER&WEBVAR_PASSWORD=$PASS" http://$HOST/rpc/WEBSES/create.asp 2> /dev/null | grep SESSION_COOKIE | cut -d\' -f 4`
curl --cookie Cookie=SessionCookie=$COOKIE http://$HOST/Java/jviewer.jnlp -o $HOST.jviewer.jnlp
Then start the jviewer.jnlp file with javaws
然后用javaws启动jviewer.jnlp文件
回答by Alexander Amelkin
Supermicro uses American Megatrends' MegaRAC software, and jviewer is a part of it. MegaRAC offers a standalone jviewer application. You should be able to request it from Supermicro.
Supermicro 使用美国 Megatrends 的 MegaRAC 软件,jviewer 是其中的一部分。MegaRAC 提供了一个独立的 jviewer 应用程序。您应该可以从 Supermicro 请求它。
回答by Maxim Akristiniy
you need connect to IPMI server and set cookie variables: WEBVAR_USERNAME, WEBVAR_PASSWORD
you will get in response in cookie variable SESSION_COOKIE
next download http://" + IP + "/Java/jviewer.jnlp?EXTRNIP=" + IP + "&JNLPSTR=JViewer
to your jnlp
您需要连接到 IPMI 服务器并设置 cookie 变量:WEBVAR_USERNAME、WEBVAR_PASSWORD
您将在 cookie 变量 SESSION_COOKIE
下一次下载 http://" + IP + "/Java/jviewer.jnlp?EXTRNIP=" + IP + "&JNLPSTR= 中得到响应JViewer
到你的 jnlp
or use existing jnlp and replace received cookie in it with your cookie :
或使用现有的 jnlp 并用您的 cookie 替换其中收到的 cookie:
<argument>-webcookie</argument>
<argument>zIoAlbnWxQtHTIutR8wyeKxeo9nAVJF5000</argument>