try (SshClient client = SshClient.setUpDefaultClient()) {
client.start();
clientSession = client.connect(config.getUsername(), config.getServerIp(), config.getSshPort()).verify().getSession();
boolean result = clientSession.auth().verify().await();
if (!result) {
throw new AgentException("Remote server ssh login failed.");
} else {
log.info("Connection to the remote server [{}] is successful.", config.getServerIp());
// Local and remote port number binding forwarding
this.portForwardingTracker = clientSession.createLocalPortForwardingTracker(new SshdSocketAddress(FORWARD_LOCAL_IP, config.getLocalPort()),
new SshdSocketAddress(config.getForwardTargetIp(), config.getForwardTargetPort()));
log.info("Port forwarding binding is completed, local port : {}, forward IP: {}, forward port : {}",
config.getLocalPort(), config.getForwardTargetIp(), config.getForwardTargetPort());
}
} catch (Exception e) {
throw new AgentException("Remote server port number forwarding failed.", e);
}
Actual behavior
sshd logs
May 27 06:37:35 node1 sshd[1367281]: Accepted publickey for root from xxx.xxx.xx port 51881 ssh2: ED25519 SHA256:k0velrxirD8HY9rq/GMBqoBI......
May 27 06:37:35 node1 sshd[1367281]: pam_unix(sshd:session): session opened for user root(uid=0) by (uid=0)
May 27 06:37:35 node1 systemd-logind[743]: New session 244 of user root.
May 27 06:37:35 node1 sshd[1367281]: pam_unix(sshd:session): session closed for user root
May 27 06:37:35 node1 systemd-logind[743]: Session 244 logged out. Waiting for processes to exit.
May 27 06:37:35 node1 systemd-logind[743]: Removed session 244.
Expected behavior
If the close method is not executed, the forwarding will continue.
Version
2.12.2
Bug description
Actual behavior
sshd logs
Expected behavior
If the close method is not executed, the forwarding will continue.
Relevant log output
No response
Other information
No response