5

我尝试在不使用 webbrowser 或 IPMIview 工具的情况下使用 IPMI 远程连接 (KVM) 进行连接。但到目前为止还没有运气。

我首先想到的是用 javaws 启动“jviewer.jnlp”。如果您按下“远程连接”按钮,该文件将由 IPMI 网站创建。此解决方案一直有效,直到 Web 会话关闭。我尝试用用户名和密码替换加密的参数。但是不知何故嵌入了会话ID。

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>

如果 jnlp 被命名为“launch.jnlp”,则参数用户名和密码替换将起作用某些 Supermicro IPMI 版本将使用不同的结构。

其次,我尝试连接 IPMIview 工具版本 2.9.32。那工作,所以连接是好的。知道我通过使用 IPMIview 的 jar 来尝试连接。用 IPMI IP 替换主机

java -Djava.library.path=. -jar iKVM.jar host ADMIN ADMIN null 5900 2623 2 0

这将打开远程连接,但会出现“连接失败”错误。

java -Djava.library.path=. -jar JViewerX9.jar host ADMIN ADMIN

同样的结果: 连接失败 连接失败带有一个警告框。确定关闭应用程序

一些 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

冷重置“ipmitool mc reset cold”也不起作用。

我希望有人知道这个参数对 jnlp 文件意味着什么,或者有人对此问题有一个可行的解决方案

编辑:我尝试了 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();
                }

            }
        }
    }

}

只是现在它会在 viewer.jnlp 文件中写入登录页面。仍然没有运气。我设法阅读了登录页面后面的 index.html 页面。但会议结束得非常快。

4

3 回答 3

9

下载 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

然后用javaws启动jviewer.jnlp文件

于 2015-01-20T08:27:32.910 回答
2

Supermicro 使用 American Megatrends 的 MegaRAC 软件,jviewer 是其中的一部分。MegaRAC 提供了一个独立的 jviewer 应用程序。您应该可以从 Supermicro 请求它。

于 2017-01-11T12:46:54.607 回答
0

您需要连接到 IPMI 服务器并设置 cookie 变量:WEBVAR_USERNAME, WEBVAR_PASSWORD
您将在 cookie 变量 SESSION_COOKIE 中得到响应
下一次下载 http://" + IP + "/Java/jviewer.jnlp?EXTRNIP=" + IP + "&JNLPSTR= JViewer
到你的 jnlp

或使用现有的 jnlp 并将其中收到的 cookie 替换为您的 cookie:

<argument>-webcookie</argument>
<argument>zIoAlbnWxQtHTIutR8wyeKxeo9nAVJF5000</argument>
于 2014-12-04T16:05:21.220 回答