However, we are also now seeing whereby after the sudo command runs that the ssh connection times out. For example if we have a simple bash script which does "date" and then "sleep 480"; and it is ran via "sudo su - /tmp/test.sh" then the output in debug mode looks like:
Start: Tue Sep 12 19:03:01 UTC 2023 Curr: Tue Sep 12 19:03:01 UTC 2023 Try: 1 of 10000
[net.schmizz.sshj.transport.TransportImpl] Dying because - Broken transport; encountered EOF
[net.schmizz.sshj.transport.TransportImpl] Disconnected - UNKNOWN
[net.schmizz.sshj.transport.KeyExchanger] Got notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
[net.schmizz.sshj.connection.ConnectionImpl] Notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
[net.schmizz.sshj.connection.channel.direct.SessionChannel] Channel #0 got notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
[net.schmizz.sshj.connection.ConnectionImpl] Forgetting `session` channel (#0)
[net.schmizz.concurrent.Promise] Setting <<chan#0 / close>> to `SOME`
[net.schmizz.sshj.transport.TransportImpl] Setting active service to null-service
Expect operation fails (timeout: 30000000 ms) for matcher: regexp('~.*\$')
[net.schmizz.concurrent.Promise] Setting <<transport close>> to `SOME`
[sshj-ssh] closing session
[net.schmizz.sshj.transport.Reader] Stopping
SSH command execution error: Unknown: net.sf.expectit.ExpectIOException: Expect operation fails (timeout: 30000000 ms) for matcher: regexp('~.*\$')
If I am reading the debug mode output correctly, it appears the underlying ssh connection has terminated during the sleep command (based upon the "Got notified of net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF").
We do have keepalive enabled:
[sshj-scp] init SSHJDefaultConfig
[sshj-scp] init SSHClient
[sshj-scp] setting timeouts
[sshj-scp] getConnectTimeout timeout: 0
[sshj-scp] getTimeout timeout: 0
[sshj-scp] keepAliveInterval: 5
[sshj-scp] adding loadKnownHosts
[sshj-scp] open connection
We keep having to revert back to Rundeck Community 4.7 version with sshj plugin version 1.2. However, we are being pushed to upgrade to the latest version. Any ideas on fixes for sshj plugin so that sudo and ssh connection keepalive work together again?