我创建了一个Amazon Linux 2实例,其中部署了一个用systemd启动的Java程序。该Java程序是一个vertx-shell应用程序,它使用Apache Mina在端口2000上启动SSH服务器。应该可以通过以下两种方式连接到SSH服务器:公钥或密码验证。
在对端口22进行经典ssh身份验证以访问我的Amazon实例之后,我可以使用密码auth连接到本地在端口2000上运行的java ssh服务器。但是,当我尝试从提供Amazon私钥的本地计算机连接到SSH服务器时,连接卡在“ debug1:本地版本字符串SSH-2.0-OpenSSH_7.5 ”行上,并在2分钟的超时后最终被拒绝:
ssh -i /Users/toto/.ssh/my_amazon_key.pem -p 2000 [email protected] -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分钟后无法通过身份验证的日志。
当然,我已经在我的Amazon安全组中签入了我打开的端口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之间是否存在冲突?
好的,我终于找到了问题所在。实际上,我必须做两件事:
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句