MrEasy opened a new issue, #473:
URL: https://github.com/apache/mina-sshd/issues/473

   ### Version
   
   2.11.0, 2.12.0, 2.12.1
   
   ### Bug description
   
   Hi team,
   
   After a recent update we encounter a change in behavior with regard to the 
disconnect procedure.
   
   Last version with expected result: 2.10.0
   Versions with unexpected ewsults: 2.11.0, 2.12.0, 2.12.1 (latest release)
   
   Starting with 2.11.0 the following issue can be seen:
   When connecting to the SSH server and issuing a command, in about 50% of all 
cases, the disconnect is not gracefully, but gives a normal exit with code 0, 
but then followed by another "unexpectedly closed" result, leading to an exit 
status of 1.
   This is in our case problematic, since we interpret the exit code as having 
issued a successful command.
   
   Environment:
   Windows (meh)
   SSH-client: PuTTY/plink, tested versions 0.70, 0.80 (latest release)
   
   The following example plink call shows the issue in about 50% of all 
executions (alternative with private-key auth as well):
   
   
   ```
   PS C:\xxx\> plink.exe -batch -l admin -P 8122 -noagent -pwfile 
"C:\xxx\pwd.txt" -v localhost "ls #execute some command"; Write-Host "`r`nLAST 
EXIT CODE: "$LASTEXITCODE
   
   Looking up host "localhost" for SSH connection
   Connecting to ::1 port 8122
   Connected to ::1
   We claim version: SSH-2.0-PuTTY_Release_0.80
   Remote version: SSH-2.0-APACHE-SSHD-2.11.0
   Using SSH protocol version 2
   Doing ECDH key exchange with curve nistp256, using hash SHA-256 
(unaccelerated)
   Host key fingerprint is:
   ssh-rsa 2048 SHA256:<sha here>
   Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
   Initialised HMAC-SHA-256 (unaccelerated) outbound MAC algorithm
   Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
   Initialised HMAC-SHA-256 (unaccelerated) inbound MAC algorithm
   Using username "admin".
   Attempting keyboard-interactive authentication
   Keyboard-interactive authentication prompts from server:
   Access granted
   EOpening main session channel
   nd of keyboard-interactive prompts from server
   Opened main channel
   Started a shell/command
   <command output here>
   Server sent command exit status 0
   Server unexpectedly closed network connection
   FATAL ERROR: Server unexpectedly closed network connection
   
   LAST EXIT CODE:  1
   ```
   
   Full output of -sshrawlog attached: 
[sshraw.log](https://github.com/apache/mina-sshd/files/14559968/sshraw.log)
   
   After setting the sshd logs to TRACE we could see this:
   ````
   close(Nio2Session[local=/127.0.0.1:8122, remote=/127.0.0.1:51820]) Closing 
gracefully 
   doCloseImmediately(Nio2Session[local=/127.0.0.1:8122, 
remote=/127.0.0.1:51820]) 
socket=sun.nio.ch.WindowsAsynchronousSocketChannelImpl[closed] closed
   
   handleReadCycleFailure(Nio2Session[local=/127.0.0.1:8122, 
remote=/127.0.0.1:51818]) IOException after 413392003 nanos at read cycle=14: 
The specified network name is no longer available
   ````
   As if it closed the connection already but then tries to do something with 
it again.
   Also put to log-output below.
   
   If we  execute the command long enough to get a successful response (only 
exit code 0, without it being followed by an exit code 1 immediatly), we see 
this in the debug logs:
   ````
   org.apache.sshd.common.io.nio2.Nio2Session  Thread-18070  
[org.apache.sshd.osgi:2.11.0]         |  |  |  |  
close(Nio2Session[local=/[0:0:0:0:0:0:0:1]:8122, 
remote=/[0:0:0:0:0:0:0:1]:59243]) Closing gracefully
   ````
   
   ### Actual behavior
   
   In about 50% of executions, the disconnect fails to execute gracefully and 
exit code 1 is the result.
   
   ### Expected behavior
   
   Graceful disconnect with exit code 0.
   
   ### Relevant log output
   
   ```Shell
   close(Nio2Session[local=/127.0.0.1:8122, remote=/127.0.0.1:51820]) Closing 
gracefully 
   doCloseImmediately(Nio2Session[local=/127.0.0.1:8122, 
remote=/127.0.0.1:51820]) 
socket=sun.nio.ch.WindowsAsynchronousSocketChannelImpl[closed] closed
   
   handleReadCycleFailure(Nio2Session[local=/127.0.0.1:8122, 
remote=/127.0.0.1:51818]) IOException after 413392003 nanos at read cycle=14: 
The specified network name is no longer available
   ```
   
   
   ### Other information
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to