![](/img/trans.png)
[英]How to access Apache Mina sshd sftp server from remote machine
[英]How to access apache mina ssh server from remote machine?
我創建了一個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 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分鍾后無法通過身份驗證的日志。
當然,我已經在我的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之間是否存在沖突?
好的,我終於找到了問題所在。 實際上,我必須做兩件事:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.