[英]How to access apache mina ssh server from remote machine?
I have created an Amazon Linux 2 instance where I have deployed a Java program launched with systemd. 我创建了一个Amazon Linux 2实例,其中部署了一个用systemd启动的Java程序。 The Java program is a vertx-shell application which is using Apache Mina to start a SSH server on port 2000. It should possible to connect to the SSH server with 2 ways : public key or password auth.
该Java程序是一个vertx-shell应用程序,它使用Apache Mina在端口2000上启动SSH服务器。应该可以通过以下两种方式连接到SSH服务器:公钥或密码验证。
After a classical ssh authentication on port 22 to access my amazon instance, I can connect to the java ssh server running on port 2000 locally with password auth. 在对端口22进行经典ssh身份验证以访问我的Amazon实例之后,我可以使用密码auth连接到本地在端口2000上运行的java ssh服务器。 However, when I try to connect to SSH server from my local machine providing the Amazon private key, the connection is stuck on ' debug1: Local version string SSH-2.0-OpenSSH_7.5 ' line and finally refused after a timeout of 2 minutes :
但是,当我尝试从提供Amazon私钥的本地计算机连接到SSH服务器时,连接卡在“ debug1:本地版本字符串SSH-2.0-OpenSSH_7.5 ”行上,并在2分钟的超时后最终被拒绝:
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
On the Java application log, I can see a log of somebody trying to connect to the SSH server but failing to authenticate after 2 minutes. 在Java应用程序日志上,我可以看到有人试图连接到SSH服务器但2分钟后无法通过身份验证的日志。
Of course, I have checked in my Amazon security group that I have opened port 2000. There is no denied IP in my case. 当然,我已经在我的Amazon安全组中签入了我打开的端口2000。在我的情况下,没有拒绝的IP。
Here is the Java code running the SSH server : 这是运行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"))))
);
Any idea ? 任何想法 ? Vertx/Apache Mina config ?
Vertx / Apache Mina配置? Conflict between SSHD running on port 22 and port 2000 ?
在端口22和端口2000上运行的SSHD之间是否存在冲突?
Ok, I finally found out the problem. 好的,我终于找到了问题所在。 Actually, I had to do 2 things :
实际上,我必须做两件事:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.