【问题标题】:SSH Reverse tunneling in AndroidAndroid中的SSH反向隧道
【发布时间】:2014-01-18 13:47:24
【问题描述】:

我正在使用 SSHJ 库建立反向 ssh 隧道但没有运气..

Error: Unable to resolve host name

使用的代码:

final SSHClient ssh = new SSHClient(new AndroidConfig());
Command cmd = null;
// Adds a nullHostKeyVerifier
ssh.addHostKeyVerifier(new NullHostKeyVerifier());
// default port number
int pn = 22;
// connect to the machine
try {
    String pemkey = "/mnt/sdcard/lamp.pem";
    ssh.loadKeys(pemkey);
    ssh.connect("-R 8080:localhost:8080 root@54.X.X.X ",pn);
    // Authenticate with the password entered
    // start a new session
    final Session session = ssh.startSession();
} catch (IOException e) {
    Log.e("message", e.getMessage(), e);
}

【问题讨论】:

  • connect 只接受一个主机名,例如ssh.connect("54.X.X.X");这种反向隧道我不知道怎么做。

标签: java android ssh


【解决方案1】:

考虑使用JSch

JSch 是 SSH2 的纯 Java 实现。

this example的使用说明:

session.setPortForwardingR(rport, lhost, lport);

【讨论】:

    猜你喜欢
    • 2012-06-06
    • 2010-09-27
    • 2018-09-01
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2020-09-15
    • 1970-01-01
    相关资源
    最近更新 更多