fragaLY commented on issue #622:
URL: https://github.com/apache/mina-sshd/issues/622#issuecomment-2410249062

   Hello @tomaswolf, 
   
   Thank you for your answer.
   
   When I am using a HostConfigEntryResolver.EMPTY it skips the PK auth.
   
   Unfortunately, now I am facing with the other problem: ```Failed to create 
SSH Client Session:No more authentication methods available```
   
   The ```ClentUserAuthService.class``` code line 331: in case of I am using a 
password auth approach if sets authFuture exception.
   
   My example:
   ```java
   import org.apache.sshd.client.SshClient;
   import org.apache.sshd.client.config.hosts.HostConfigEntryResolver;
   import org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier;
   import org.apache.sshd.client.session.ClientSession;
   import org.apache.sshd.common.auth.UserAuthMethodFactory;
   
   import java.io.IOException;
   import java.util.List;
   import java.util.Objects;
   import java.util.concurrent.TimeUnit;
   
   public class Main {
   
       private static final int DEFAULT_SFTP_SESSION_TIMEOUT = 2500;
   
       public static void main(String[] args) throws IOException {
           SshClient client = null;
           ClientSession session = null;
           try {
               client = SshClient.setUpDefaultClient();
               client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
               client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY);
               
client.setUserAuthFactoriesNames(List.of(UserAuthMethodFactory.PASSWORD));
               client.start();
               session = client.connect("user", "host",  
22).verify(DEFAULT_SFTP_SESSION_TIMEOUT, TimeUnit.MILLISECONDS).getSession();
               session.addPasswordIdentity("password");
               session.auth().verify();
               System.out.println(session);
           } catch (Exception e) {
               var message = "Failed to create SSH Client Session:" + 
e.getMessage();
               System.out.println(message);
           } finally {
               Objects.requireNonNull(session).close();
               Objects.requireNonNull(client).close();
           }
       }
   }
   
   


-- 
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

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