代码之家  ›  专栏  ›  技术社区  ›  rico

如何从远程机器访问apacheminash服务器?

  •  0
  • rico  · 技术社区  · 8 年前

    在端口22上进行经典ssh身份验证以访问我的amazon实例之后,我可以使用password auth本地连接到在端口2000上运行的javassh服务器。但是,当我试图从提供Amazon私钥的本地计算机连接到SSH服务器时,连接被卡住了 debug1:本地版本字符串SSH-2.0-OpenSSH\u 7.5

    ssh -i /Users/toto/.ssh/my_amazon_key.pem -p 2000 ec2-user@my-application.server.com -vvv
    OpenSSH_7.5p1, LibreSSL 2.5.4
    debug1: Reading configuration data /Users/toto/.ssh/config
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 52: Applying options for *
    debug2: resolving "my-application.server.com" port 2000
    debug2: ssh_connect_direct: needpriv 0
    debug1: Connecting to my-application.server.com [35.XXX.XX.XX] port 2000.
    debug1: Connection established.
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/toto/.ssh/my_amazon_key.pem type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/toto/.ssh/my_amazon_key.pem-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.5
    ssh_exchange_identification: Connection closed by remote host
    

    在Java应用程序日志中,我可以看到一个日志,其中有人试图连接到SSH服务器,但在2分钟后未能进行身份验证。

    当然,我已经在我的亚马逊安全组检查了我已经打开了2000端口。在我的情况下没有被拒绝的IP。

    以下是运行SSH服务器的Java代码:

    ShellService service = ShellService.create(vertx,
                    new ShellServiceOptions()
                            .setTelnetOptions(
                                new TelnetTermOptions().
                                    setHost("localhost").
                                    setPort(5000))
                            .setSSHOptions(
                                new SSHTermOptions().
                                    setHost("0.0.0.0").
                                    setPort(2000).
                                    setKeyPairOptions(new JksOptions().
                                            setPath("ssh/keystore.jks").
                                            setPassword("wibble")).
                                    setAuthOptions(new ShiroAuthOptions().
                                            setConfig(new JsonObject().put("properties_path", "classpath:ssh/auth.properties"))))
            );
    

    你知道吗?Vertx/Apache Mina配置?在端口22和端口2000上运行的SSHD之间存在冲突?

    1 回复  |  直到 8 年前
        1
  •  0
  •   rico    8 年前

    1. 我用一个特定的用户vertx启动java应用程序,因此apacheminashsh服务器正在为用户vertx寻找一个不存在的授权密钥文件。一旦我在vertx user home目录中自己的.ssh目录中创建了它,并且拥有正确的权限,那么我就可以通过提供相应私钥的身份验证。