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

   ### Version
   
   2.13.2
   
   ### Bug description
   
   the mina sshd 2.13.2 has problem to parse follow code:
   
   private ClientSession getSessionUsingJumpHost(
       SshClient sshClient, CommandObject commandObject)
       throws OcmdException, IOException
     {
       String hostName = commandObject.getNode();
       String user = commandObject.getUser();
       int port = Constants.getSSHPort();
   
       // configure the bastion entry
       HostConfigEntry bastion = new HostConfigEntry();
       bastion.setHost(Constants.getTunnelHost());
       bastion.setHostName(Constants.getTunnelHost());
       bastion.setUsername(Constants.getTunnelHostUser());
       bastion.setPort(port);
       bastion.setIdentities(
         Collections.singleton(Constants.getTunnelHostUserKey()));
   
       // configure the generate target entry
       HostConfigEntry targetHost = new HostConfigEntry();
       targetHost.setHost("*"); // for all include hostname/ip
       targetHost.setProxyJump(Constants.getTunnelHost());
   
       HostConfigEntryResolver resolver =
         HostConfigEntry.toHostConfigEntryResolver(
           GenericUtils.asList(bastion, targetHost));
   
       sshClient.setHostConfigEntryResolver(resolver);
   
       // enable the public auth
       sshClient.setUserAuthFactories( Collections.unmodifiableList(
         Arrays.asList(
           UserAuthPublicKeyFactory.INSTANCE,
           UserAuthPasswordFactory.INSTANCE,
           UserAuthKeyboardInteractiveFactory.INSTANCE
         )));
   
       // now try to connect using proxy
       try
       {
         ClientSession session = sshClient.connect(user, hostName, port)
           .verify(sessionConnectTimeout)
           .getSession();
         return session;
       }
       catch (Exception ex)
       {
         throw  ex;
       }
     }
   
   
   above code work in mina sshd 2.12.1.
   
   ### Actual behavior
   
   The Mina SSHD code in SshClient.parseProxyJumps(HostConfigEntry entry, 
AttributeRepository context) method has an issue with identifying the variable 
"additionalHops" , and it causes the list object "hops" continuously grow to 
the maximum limit of 10, and then throw  the IlllegalArgumentException.
   
![issue1](https://github.com/user-attachments/assets/92ca3140-61ba-4cdf-9107-474eee75dfb7)
   
![issue2](https://github.com/user-attachments/assets/2ae596a4-a0f5-4e2b-9326-788eabef3f3b)
   
   please check the attached debug images
   
   ### Expected behavior
   
   I think in SshClient.parseProxyJumps() need to check if the return values of 
"additionalHops" is  already in the "hops", it need to stop and return without 
throw exception
   
   ### 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