GabriRuflex commented on issue #847:
URL: https://github.com/apache/mina-sshd/issues/847#issuecomment-3446620044

   @tomaswolf I updated the title and the description.
   
   The problem was simple (though not obvious to me, thanks for the help): even 
though I had defined the auth methods in the environment parameters, the 
FileSystemProvider ignored them, causing too many connection attempts and the 
server resetting the connection.
   
   Defining the SshClient separately and then passing it to 
SftpFileSystemProvider worked for me.
   
   IMHO, it would be much more convenient if the `FileSystemProvider` could 
respect the environment parameters directly.
   This would avoid additional boilerplate code, making the code more readable 
and maintainable.
   
   This code worked for me:
   ```
   try (SshClient client = SshClient.setUpDefaultClient()) {
       
client.setUserAuthFactories(Collections.singletonList(UserAuthPasswordFactory.INSTANCE));
       client.start();
   
       try (FileSystem fs = new SftpFileSystemProvider(client)
               .newFileSystem(uri, Collections.emptyMap())) {
   ...
       }
   }
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to