无法通过远程服务器 运行 apache karaf 4.3.3 的客户端命令

unable to run client command for apache karaf 4.3.3 through remote server

我已经在几台 Ubuntu18 机器上下载了 apache karaf 4.3.3。当我尝试通过客户端安装功能或 运行 任何命令时,我得到以下日志跟踪。当我在服务器上时,我可以 运行 客户端,但它通过脚本失败。

我正在使用的命令是

$KARAF_HOME/bin/start
$KARAF_HOME/bin/client -u karaf -p karaf "features:install myfeature"
1155 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 376 bytes
1155 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - handleKexInit(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) SSH_MSG_KEXINIT
1181 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - setNegotiationResult([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], aes128-ctr, hmac-sha2-256, none]) Kex: server->client null {} {}
1181 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - setNegotiationResult([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], aes128-ctr, hmac-sha2-256, none]) Kex: client->server null {} {}
1268 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.kex.DHGClient - init(DHGClient[ecdh-sha2-nistp521])[ClientSessionImpl[karaf@localhost/127.0.0.1:8101]] Send SSH_MSG_KEXDH_INIT
1268 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 1, 30, 30, 138]) packet #null sending command={}[{}] len={}
1269 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 152 bytes
1285 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=152
1322 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 712 bytes
1325 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.kex.DHGClient - next([DHGClient[ecdh-sha2-nistp521], ClientSessionImpl[karaf@localhost/127.0.0.1:8101], SSH_MSG_KEXDH_REPLY])[null] process command={}
1384 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - handleKexMessage([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ecdh-sha2-nistp521, 31])[null] KEX processing complete after cmd={}
1384 [sshd-SshClient[4f209819]-nio2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at localhost/127.0.0.1:8101 presented unverified RSA key: SHA256:L7f8vYz8AGuXY9JOATcykbVn2IeyR2AVDLYudN7r9bw
1385 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - checkKeys([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ssh-rsa, SHA256:L7f8vYz8AGuXY9JOATcykbVn2IeyR2AVDLYudN7r9bw, true]) key=null-{}, verified={}
1385 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - sendNewKeys(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Send SSH_MSG_NEWKEYS
1385 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 2, 21, SSH_MSG_NEWKEYS, 1]) packet #null sending command={}[{}] len={}
1385 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 16 bytes
1396 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=16
1397 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 16 bytes
1397 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - handleNewKeys(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) SSH_MSG_NEWKEYS command=SSH_MSG_NEWKEYS
1397 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - receiveNewKeys(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) session ID=8c:46:43:0f:d1:11:8f:f7:ed:eb:40:b1:29:64:86:52:0f:34:f0:60:00:7f:69:df:d9:a8:ec:dc:36:27:95:d2:38:d2:e9:39:e7:8b:fd:8b:b4:0c:81:4a:7d:58:57:2b:cf:76:43:50:b5:de:e2:45:72:61:b7:b6:5f:1e:a2:5c
1422 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - receiveNewKeys([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], BaseCipher[AES, ivSize=16, kdfSize=16,AES/CTR/NoPadding, blkSize=16], BaseCipher[AES, ivSize=16, kdfSize=16,AES/CTR/NoPadding, blkSize=16], 4294967296, 4294967296]) inCipher=null, outCipher={}, recommended blocks limit={}, actual={}
1422 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - sendInitialServiceRequest(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Send SSH_MSG_SERVICE_REQUEST for ssh-userauth
1423 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 3, 5, SSH_MSG_SERVICE_REQUEST, 17]) packet #null sending command={}[{}] len={}
1423 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 80 bytes
1423 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=80
1424 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 4, 50, SSH_MSG_USERAUTH_REQUEST, 36]) packet #null sending command={}[{}] len={}
1424 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 96 bytes
1424 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=96
1424 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientSessionImpl - handleNewKeys(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) sent 1 pending packets
1426 [sshd-SshClient[4f209819]-nio2-thread-1] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 80 bytes
1427 [sshd-SshClient[4f209819]-nio2-thread-1] DEBUG org.apache.sshd.client.session.ClientSessionImpl - handleServiceAccept(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) SSH_MSG_SERVICE_ACCEPT service=ssh-userauth
1428 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 112 bytes
1428 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - processUserAuth([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], false, keyboard-interactive,password,publickey]) Received SSH_MSG_USERAUTH_FAILURE - partial=null, methods={}
1428 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], [publickey, keyboard-interactive, password], [keyboard-interactive, password, publickey]]) starting authentication mechanisms: client=null, server={}
1430 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) attempting method=publickey
1446 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.config.keys.DefaultClientIdentitiesWatcher - loadKeys(/root/.ssh/id_rsa) no key loaded
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.config.keys.DefaultClientIdentitiesWatcher - loadKeys(/root/.ssh/id_dsa) no key loaded
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.config.keys.DefaultClientIdentitiesWatcher - loadKeys(/root/.ssh/id_ecdsa) no key loaded
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.config.keys.DefaultClientIdentitiesWatcher - loadKeys(/root/.ssh/id_ed25519) no key loaded
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.pubkey.UserAuthPublicKey - sendAuthDataRequest(ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[ssh-connection] no more keys to send
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) no initial request sent by method=publickey
1447 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.pubkey.UserAuthPublicKey - destroy(ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[ssh-connection]
1448 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) attempting method=keyboard-interactive
1449 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - verifyTrialsCount([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ssh-connection, SSH_MSG_USERAUTH_REQUEST, 0, 3])[null] cmd={} - {} out of {}
1449 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - sendAuthDataRequest([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ssh-connection, keyboard-interactive, , ])[null] send SSH_MSG_USERAUTH_REQUEST for {}: lang={}, methods={}
1449 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 5, 50, SSH_MSG_USERAUTH_REQUEST, 60]) packet #null sending command={}[{}] len={}
1449 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 128 bytes
1454 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=128
1455 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - tryNext(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) successfully processed initial buffer by method=keyboard-interactive
1455 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 128 bytes
1455 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientUserAuthService - processUserAuth([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 60, keyboard-interactive]) delegate processing of null to {}
1455 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - processAuthDataRequest([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ssh-connection, Password authentication, , en-US, 1])[null] SSH_MSG_USERAUTH_INFO_REQUEST name={}, instruction={}, language={}, num-prompts={}
1455 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - verifyTrialsCount([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], ssh-connection, SSH_MSG_USERAUTH_INFO_REQUEST, 1, 3])[null] cmd={} - {} out of {}
1456 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - getUserResponses(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) use password candidate for interaction=Password authentication
1456 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.client.session.ClientSessionImpl - encode([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 6, 61, SSH_MSG_USERAUTH_INFO_RESPONSE, 14]) packet #null sending command={}[{}] len={}
1456 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - writePacket(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Writing 80 bytes
1458 [sshd-SshClient[4f209819]-nio2-thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleCompletedWriteCycle(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) finished writing len=80
1529 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - handleReadCycleCompletion(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) read 64 bytes
1529 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientUserAuthService - processUserAuth(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) SSH_MSG_USERAUTH_SUCCESS Succeeded with keyboard-interactive
1530 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.auth.keyboard.UserAuthKeyboardInteractive - destroy(ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[ssh-connection]
1530 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientConnectionService - stopHeartBeat(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) no heartbeat to stop
1532 [sshd-SshClient[4f209819]-nio2-thread-3] DEBUG org.apache.sshd.client.session.ClientConnectionService - startHeartbeat([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 60000, keepalive@sshd.apache.org]) - started at interval=null with request={}
1799 [main] DEBUG org.apache.sshd.client.channel.ChannelExec - init() service=[ClientConnectionService[ClientSessionImpl[karaf@localhost/127.0.0.1:8101]], ClientSessionImpl[karaf@localhost/127.0.0.1:8101], 0] session=null id={}
1800 [main] DEBUG org.apache.sshd.common.channel.Window - init([Window[client/local](ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]), 2097152, 2097152, 32768]) size=null, max={}, packet={}
1800 [main] DEBUG org.apache.sshd.client.session.ClientConnectionService - registerChannel([ClientConnectionService[ClientSessionImpl[karaf@localhost/127.0.0.1:8101]], 0, ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]])[id=null] {}
1800 [main] DEBUG org.apache.sshd.client.session.ClientSessionImpl - createExecChannel([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], bundle:list 
, 0, null])[null] created id={} - PTY={}
1811 [Thread-2] DEBUG org.apache.sshd.client.channel.ChannelExec - close(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Closing immediately
1811 [Thread-2] DEBUG org.apache.sshd.client.channel.ChannelExec - close(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) prevent sending EOF
1811 [main] DEBUG org.apache.sshd.client.channel.ChannelExec - open(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Send SSH_MSG_CHANNEL_OPEN - type=session
1811 [Thread-2] DEBUG org.apache.sshd.common.channel.Window - Closing Window[client/local](ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101])
1811 [main] DEBUG org.apache.sshd.client.channel.ChannelExec - writePacket(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Discarding output packet because channel state=Immediate
1811 [Thread-2] DEBUG org.apache.sshd.common.channel.Window - Closing Window[client/remote](ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101])
1816 [main] DEBUG org.apache.sshd.client.SshClient - close(SshClient[4f209819]) Closing immediately
1817 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Connector - close(org.apache.sshd.common.io.nio2.Nio2Connector@1b1426f4) Closing immediately
1818 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - close(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) Closing immediately
1818 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - doCloseImmediately(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) closing socket=sun.nio.ch.UnixAsynchronousSocketChannelImpl[connected local=/127.0.0.1:45906 remote=localhost/127.0.0.1:8101]
1819 [sshd-SshClient[4f209819]-nio2-thread-1] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - close(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101])[Immediately] state already Immediate
1820 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - doCloseImmediately(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]) socket=sun.nio.ch.UnixAsynchronousSocketChannelImpl[closed] closed
1820 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Connector - unmapSession(id=101): Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101]
1820 [main] DEBUG org.apache.sshd.client.session.ClientSessionImpl - close(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) Closing immediately
1820 [main] DEBUG org.apache.sshd.client.session.ClientSessionImpl - signalAuthFailure([ClientSessionImpl[karaf@localhost/127.0.0.1:8101], SshException, false, Session is being closed]) type=null, signalled={}: {}
1821 [main] DEBUG org.apache.sshd.client.session.ClientConnectionService - close(ClientConnectionService[ClientSessionImpl[karaf@localhost/127.0.0.1:8101]]) Closing immediately
1821 [main] DEBUG org.apache.sshd.client.session.ClientConnectionService - stopHeartBeat(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) stopping
1821 [main] DEBUG org.apache.sshd.client.session.ClientConnectionService - stopHeartBeat(ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) stopped
1821 [main] DEBUG org.apache.sshd.client.channel.ChannelExec - close(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[Immediately] state already Immediate
1822 [main] DEBUG org.apache.sshd.client.session.ClientConnectionService - close(ClientConnectionService[ClientSessionImpl[karaf@localhost/127.0.0.1:8101]])[Immediately] closed
1822 [main] DEBUG org.apache.sshd.client.session.ClientSessionImpl - close(ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[Immediately] closed
1822 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - close(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101])[Immediately] closed
1822 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Connector - close(org.apache.sshd.common.io.nio2.Nio2Connector@1b1426f4)[Immediately] closed
1822 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - close(org.apache.sshd.common.io.nio2.Nio2ServiceFactory@71238fc2) Closing immediately
1822 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown group
1831 [Thread-2] DEBUG org.apache.sshd.common.channel.AbstractChannel$GracefulChannelCloseable - close(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[immediately=true] processing
1831 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Group successfully shut down
1831 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown executor
1835 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown complete
1835 [Thread-2] DEBUG org.apache.sshd.client.session.ClientConnectionService - unregisterChannel(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]) result=ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]
1835 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - close(org.apache.sshd.common.io.nio2.Nio2ServiceFactory@71238fc2)[Immediately] closed
1835 [Thread-2] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable@51fc526d) signal close complete immediately=true
1835 [Thread-2] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable@5b38138a) signal close complete immediately=true
1835 [Thread-2] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable@a890633) signal close complete immediately=true
1835 [main] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable@16a0ee18) signal close complete immediately=true
1835 [Thread-2] DEBUG org.apache.sshd.common.io.nio2.Nio2Session - close(Nio2Session[local=/127.0.0.1:45906, remote=localhost/127.0.0.1:8101])[Immediately] state already Closed
1835 [main] DEBUG org.apache.sshd.client.SshClient - close(SshClient[4f209819])[Immediately] closed
1835 [Thread-2] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable@3b9b6f68) signal close complete immediately=true
1836 [Thread-2] DEBUG org.apache.sshd.client.channel.ChannelExec - close(ChannelExec[id=0, recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101])[Immediately] closed
org.apache.sshd.common.SshException: Closed
    at org.apache.sshd.common.util.closeable.FuturesCloseable.doClose(FuturesCloseable.java:47)
    at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.operationComplete(SequentialCloseable.java:56)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.operationComplete(SequentialCloseable.java:45)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69)
    at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.operationComplete(SequentialCloseable.java:56)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.operationComplete(SequentialCloseable.java:45)
    at org.apache.sshd.common.util.closeable.SequentialCloseable.doClose(SequentialCloseable.java:69)
    at org.apache.sshd.common.util.closeable.SimpleCloseable.close(SimpleCloseable.java:63)
    at org.apache.sshd.common.util.closeable.AbstractInnerCloseable.doCloseImmediately(AbstractInnerCloseable.java:48)
    at org.apache.sshd.common.util.closeable.AbstractCloseable.close(AbstractCloseable.java:95)
    at org.apache.karaf.client.Main.lambda$main(Main.java:196)
    at java.base/java.lang.Thread.run(Thread.java:829)

有人知道为什么会这样吗?跟钥匙有关系吗?如果是,那我应该改变什么?

我遇到了类似的问题,脚本返回“已关闭”状态。

经过一些测试,我发现脚本在没有 TTY 时失败(如果你使用像 ansible 这样的工具就是这种情况)

您应该使用包含在 karaf 客户端脚本中的 'batch mode',因此您的命令将变为:

$KARAF_HOME/bin/client -u karaf -p karaf -b <<< "features:install myfeature"

当 运行 这种方式时,脚本不会请求 TTY,但会 运行 来自标准输入的命令。在我的示例中,我使用 'here string' 重定向到标准输入,但您当然可以使用任何您喜欢的重定向将命令传递到标准输入

如果您更喜欢从文件中读取命令,还有一个“-f”选项。 详情见bin/client --help

或者,如果您可以控制 ssh 命令,则可以使用 ssh 上的选项在连接到远程计算机时强制分配 tty:

ssh -o RequestTTY=force my_server $KARAF_HOME/bin/client -u karaf -p karaf "features:install myfeature"

(参见https://man7.org/linux/man-pages/man5/ssh_config.5.html

我使用上面的答案构建了一个使用以下模式对我有用的解决方案

`ssh -o RequestTTY=force -o StrictHostKeyChecking=no karaf_user@localhost -p KARAF_SSH_PORT -i "/ssh/key" "karaf_command"` 

这使用 karaf 打包的 ssh 服务器,客户端命令在内部包装以通过 ssh 发出 karaf 控制台命令。这种方法要求您在 keys.properties 文件中为您的 karaf 用户放置一个 public 密钥,并使用私钥进行 ssh。 欲了解更多详情,请参阅: