Dark Matter
Dark Matter

Reputation: 97

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

I have downloaded apache karaf 4.3.3 on several Ubuntu18 machine. When I try to install feature or run any command through client, I get the below log trace. I am able to run the client when I am on the server, but it fails through the script.

command i'm using are

$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, [email protected]]) - 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$1@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$1@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$1@a890633) signal close complete immediately=true
1835 [main] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - doClose(org.apache.sshd.common.util.closeable.SequentialCloseable$1@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$1@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$1.operationComplete(SequentialCloseable.java:56)
    at org.apache.sshd.common.util.closeable.SequentialCloseable$1.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$1.operationComplete(SequentialCloseable.java:56)
    at org.apache.sshd.common.util.closeable.SequentialCloseable$1.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$1(Main.java:196)
    at java.base/java.lang.Thread.run(Thread.java:829)

Anyone know why this is happening? is it to do with the keys? if so then what should i change?

Upvotes: 2

Views: 1822

Answers (3)

Jin Cong Ho
Jin Cong Ho

Reputation: 31

Also encountered this issue on Kubernetes getting "Closed", trying to run karaf client in a startup script. After some debugging, this is the cause: link. The commit actively closes the ssh client session if stdin is empty (which is the case if you only have one command). The latest Karaf still has this, so batch mode is the solution until there's a fix.

Upvotes: 1

I came across a similar problem with the script returning a "Closed" status.

After some tests, I found the script fails when there is no TTY (as is the case if you use tools like ansible)

You should use the 'batch mode' included in karaf client script, so your command would become:

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

This way, the script won't ask for a TTY but will run the commands from standard input. In my example I use a 'here string' to redirect to the standard input, but you could of course use any redirection you like to pass commands to the standard input

There is also a '-f' option if you prefer to read commands from a file. See bin/client --help for details

Alternatively, if you have control of the ssh commands, you could use the option on ssh to force tty allocation when connecting to your remote machine:

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

(see https://man7.org/linux/man-pages/man5/ssh_config.5.html)

Upvotes: 3

ATM
ATM

Reputation: 26

I used the above answer to construct a solution that worked for me using the following pattern

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

This uses the ssh server that karaf is packaged with and the client command wraps internally to make karaf console commands over ssh. This approach requires you to put a public key for your karaf user in the keys.properties file and ssh using a private key. For more details see:

Upvotes: 1

Related Questions