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

   ### Version
   
   2.9.2
   
   ### Bug description
   
   I have a ~/.ssh/config similar to this:
   
   ```
   Host bastion
     Hostname 1.2.3.4
     User username
     IdentityFile ~/.ssh/id_rsa
   
   Host server1
     ProxyJump bastion
   ```
   Commandline ssh client works no problem for calls such as 
   ```
   ssh serverUser@server1
   ssh bastion
   ```
   and correctly assume port 22 is to be used.
   However the sshClient does not assume default port for jumps, and results in 
exception:
   ```
   try(SshClient sshClient = SshClient.setUpDefaultClient()) {
       sshClient.setHostConfigEntryResolver(new 
ConfigFileHostEntryResolver(sshConfigFile));
       sshClient.start();
       sshClient.connect("serverUser", "server1", 22);
   } catch (Exception e) {
       throw new IllegalStateException(e);
   }
   ```
   
   
     
   
   ### Actual behavior
   
   The jump entry is resolved as `bastion: username@1.2.3.4:-1`
   ```
   Caused by: java.lang.IllegalArgumentException: Invalid port: -1
        at 
org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
 ~[sshd-common-2.9.2.jar:2.9.2]
        at 
org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179)
 ~[sshd-common-2.9.2.jar:2.9.2]
        at 
org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:162) 
~[sshd-common-2.9.2.jar:2.9.2]
        at org.apache.sshd.client.SshClient.doConnect(SshClient.java:556) 
~[sshd-core-2.9.2.jar:2.9.2]
        at org.apache.sshd.client.SshClient.doConnect(SshClient.java:568) 
~[sshd-core-2.9.2.jar:2.9.2]
        at org.apache.sshd.client.SshClient.connect(SshClient.java:546) 
~[sshd-core-2.9.2.jar:2.9.2]
        at org.apache.sshd.client.SshClient.connect(SshClient.java:538) 
~[sshd-core-2.9.2.jar:2.9.2]
        at 
org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:74)
 ~[sshd-core-2.9.2.jar:2.9.2]
        at 
org.apache.sshd.client.session.ClientSessionCreator.connect(ClientSessionCreator.java:57)
 ~[sshd-core-2.9.2.jar:2.9.2]
   ```
   
   
   ### Expected behavior
   
   Perhaps 
`org.apache.sshd.client.config.hosts.HostConfigEntry#resolvePort(int, int)` 
when given two invalid arguments:
   originalPort = -1 // from parsing URI
   entryPort = 0 // from 
   should resolve to protocol default, and act the same way as commandline 
client would given the same set of data?
   
   ### Relevant log output
   
   _No response_
   
   ### 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