Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SSHJ尝试启动会话会导致SSH\u MSG\u未实现_Java_Ssh_Sshj - Fatal编程技术网

Java SSHJ尝试启动会话会导致SSH\u MSG\u未实现

Java SSHJ尝试启动会话会导致SSH\u MSG\u未实现,java,ssh,sshj,Java,Ssh,Sshj,我在Windows机器上,我需要编写一些Java代码,通过SSH连接到远程Solaris机器,然后可以在上面执行命令并获得它们的输出,但我在身份验证方面遇到了一些问题。(我正在使用SSHJ 0.8.1) 以下是连接和启动会话的代码: public void init(String address, int portNumber, String hostKeyVerifier) throws IOException { client = new SSHClient(); c

我在Windows机器上,我需要编写一些Java代码,通过SSH连接到远程Solaris机器,然后可以在上面执行命令并获得它们的输出,但我在身份验证方面遇到了一些问题。(我正在使用SSHJ 0.8.1)

以下是连接和启动会话的代码:

public void init(String address, int portNumber, String hostKeyVerifier) throws IOException {
      client = new SSHClient();
      client.getConnection().setTimeout(300);
      client.addHostKeyVerifier(hostKeyVerifier); 
      client.connect(address, portNumber); 
      client.authPassword("user", "password");
      session = client.startSession();
   }
我希望这会产生一个工作连接,因为尝试使用相同的代码(尽管使用不同的主机密钥验证器、地址、端口和凭据)连接到ApacheKaraf实例是可行的。相反,这是我得到的输出:

16:27:58.029 [main] INFO  n.schmizz.sshj.common.SecurityUtils - BouncyCastle not registered, using the default JCE provider
16:27:58.159 [main] INFO  n.s.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0_8_1_SNAPSHOT
16:27:58.159 [main] INFO  n.s.sshj.transport.TransportImpl - Server identity string: SSH-2.0-Sun_SSH_2.2
16:27:58.159 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `null`
16:27:58.159 [main] DEBUG n.s.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
16:27:58.169 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `SOME`
16:27:58.169 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<kex done>>
16:27:58.189 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
16:27:58.189 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Negotiated algorithms: [ kex=diffie-hellman-group1-sha1; sig=ssh-rsa; c2sCipher=aes128-ctr; s2cCipher=aes128-ctr; c2sMAC=hmac-sha1; s2cMAC=hmac-sha1; c2sComp=none; s2cComp=none ]
16:27:58.209 [reader] DEBUG net.schmizz.sshj.transport.kex.DHG1 - Sending SSH_MSG_KEXDH_INIT
16:27:58.239 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Received kex followup data
16:27:58.239 [reader] DEBUG net.schmizz.sshj.transport.kex.DHG1 - Received SSH_MSG_KEXDH_REPLY
16:27:58.249 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Trying to verify host key with net.schmizz.sshj.SSHClient$1@135bdd3
16:27:58.249 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS
16:27:58.249 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS
16:27:58.249 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kexinit sent>> to `null`
16:27:58.249 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<kex done>> to `SOME`
16:27:58.249 [main] DEBUG net.schmizz.sshj.SSHClient - Key exchange took 0.09 seconds
16:27:58.249 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `null`
16:27:58.249 [main] DEBUG n.s.sshj.transport.TransportImpl - Sending SSH_MSG_SERVICE_REQUEST for ssh-userauth
16:27:58.249 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<service accept>>
16:27:58.309 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<service accept>> to `SOME`
16:27:58.309 [main] DEBUG n.s.sshj.transport.TransportImpl - Setting active service to ssh-userauth
16:27:58.309 [main] DEBUG n.schmizz.sshj.userauth.UserAuthImpl - Trying `password` auth...
16:27:58.309 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `null`
16:27:58.309 [main] DEBUG n.s.s.userauth.method.AuthPassword - Requesting password for [AccountResource] kc@10.82.82.6
16:27:58.309 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>>
16:28:28.320 [main] DEBUG n.schmizz.sshj.userauth.UserAuthImpl - `password` auth failed
16:28:28.320 [main] DEBUG n.schmizz.sshj.userauth.UserAuthImpl - Saving for later - net.schmizz.sshj.userauth.UserAuthException: Timeout expired
16:28:28.320 [main] DEBUG n.schmizz.sshj.userauth.UserAuthImpl - Trying `keyboard-interactive` auth...
16:28:28.321 [main] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `null`
16:28:28.321 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<authenticated>>
16:28:43.363 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<authenticated>> to `SOME`
16:28:43.363 [main] DEBUG n.schmizz.sshj.userauth.UserAuthImpl - `keyboard-interactive` auth successful
16:28:43.365 [main] DEBUG n.s.sshj.transport.TransportImpl - Setting active service to ssh-connection
16:28:43.366 [main] DEBUG n.s.sshj.connection.ConnectionImpl - Attaching `session` channel (#0)
16:28:43.366 [main] DEBUG net.schmizz.concurrent.Promise - Awaiting <<chan#0 / open>>
16:29:28.387 [reader] DEBUG n.s.sshj.transport.TransportImpl - Received SSH_MSG_UNIMPLEMENTED #5
16:29:28.397 [reader] ERROR n.s.sshj.transport.TransportImpl - Dying because - net.schmizz.sshj.common.SSHException: [PROTOCOL_ERROR] Unexpected: SSH_MSG_UNIMPLEMENTED
16:29:28.397 [reader] INFO  n.s.sshj.transport.TransportImpl - Disconnected - PROTOCOL_ERROR
16:29:28.398 [reader] DEBUG n.s.sshj.transport.KeyExchanger - Got notified of net.schmizz.sshj.common.SSHException: [PROTOCOL_ERROR] Unexpected: SSH_MSG_UNIMPLEMENTED
16:29:28.398 [reader] DEBUG n.s.sshj.connection.ConnectionImpl - Notified of net.schmizz.sshj.common.SSHException: [PROTOCOL_ERROR] Unexpected: SSH_MSG_UNIMPLEMENTED
16:29:28.398 [reader] DEBUG n.s.s.c.c.direct.SessionChannel - Channel #0 got notified of net.schmizz.sshj.common.SSHException: [PROTOCOL_ERROR] Unexpected: SSH_MSG_UNIMPLEMENTED
16:29:28.398 [reader] DEBUG n.s.sshj.connection.ConnectionImpl - Forgetting `session` channel (#0)
16:29:28.398 [main] ERROR net.schmizz.concurrent.Promise - <<chan#0 / open>> woke to: net.schmizz.sshj.connection.ConnectionException: Unexpected: SSH_MSG_UNIMPLEMENTED
16:29:28.398 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<chan#0 / close>> to `SOME`
16:29:28.398 [reader] DEBUG n.s.sshj.transport.TransportImpl - Setting active service to null-service
16:29:28.398 [reader] DEBUG n.s.sshj.transport.TransportImpl - Sending SSH_MSG_DISCONNECT: reason=[PROTOCOL_ERROR], msg=[Unexpected: SSH_MSG_UNIMPLEMENTED]
16:29:28.398 [reader] DEBUG net.schmizz.concurrent.Promise - Setting <<transport close>> to `SOME`
16:29:28.398 [reader] DEBUG net.schmizz.sshj.transport.Reader - Stopping
PuTTY能够使用相同的凭据连接到相同的地址和端口,没有任何问题,尽管这确实需要一些时间。我应该怎么做才能在这里获得与Java的工作连接?

我在这里看到了类似的帖子:
net.schmizz.sshj.connection.ConnectionException: Unexpected: SSH_MSG_UNIMPLEMENTED
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)
    at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26)
    at net.schmizz.concurrent.Promise.deliverError(Promise.java:95)
    at net.schmizz.concurrent.Event.deliverError(Event.java:72)
    at net.schmizz.concurrent.ErrorDeliveryUtil.alertEvents(ErrorDeliveryUtil.java:34)
    at net.schmizz.sshj.connection.channel.AbstractChannel.notifyError(AbstractChannel.java:241)
    at net.schmizz.sshj.connection.channel.direct.SessionChannel.notifyError(SessionChannel.java:249)
    at net.schmizz.sshj.common.ErrorNotifiable$Util.alertAll(ErrorNotifiable.java:35)
    at net.schmizz.sshj.connection.ConnectionImpl.notifyError(ConnectionImpl.java:250)
    at net.schmizz.sshj.transport.TransportImpl.die(TransportImpl.java:578)
    at net.schmizz.sshj.transport.Reader.run(Reader.java:79)
Caused by: net.schmizz.sshj.common.SSHException: [PROTOCOL_ERROR] Unexpected: SSH_MSG_UNIMPLEMENTED
    at net.schmizz.sshj.AbstractService.notifyUnimplemented(AbstractService.java:66)
    at net.schmizz.sshj.transport.TransportImpl.gotUnimplemented(TransportImpl.java:555)
    at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:490)
    at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:127)
    at net.schmizz.sshj.transport.Decoder.received(Decoder.java:195)
    at net.schmizz.sshj.transport.Reader.run(Reader.java:72)