DukeCharles opened a new issue, #661: URL: https://github.com/apache/mina-sshd/issues/661
### Version 2.14.0 ### Bug description The apache mina sshClient is unable to find the sftp server running on WSL on the same machine using the hostname "localhost" and "127.0.0.1". I was able to connect to the server using : OpenSSH_for_Windows_9.5p1 a.ka the sftp command in cmd/powershell winscp version 6.3.6 Paramiko library for python all of the them were using the following parameters: host = "localhost" port = "22" with correct wsl username and password **how to reproduce** 1. Open powershell and run the command : `wsl --install Ubuntu-24.04` Create an account for the linux distro 2. Run the following command in order to install and start your SFTP server `sudo apt update` `sudo apt install openssh-server` `sudo service ssh restart` Now validate that the service is running ` sudo service ssh status` Now you should have your sftp server running Now create a maven project with the following dependency in Pom ```xml <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-sftp</artifactId> <version>2.14.0</version> </dependency> ``` ```xml <dependency> <groupId>org.apache.sshd</groupId> <artifactId>sshd-core</artifactId> <version>2.14.0</version> </dependency> ``` Now run this code : ```java public static void main( String[] args ) { String host = "localhost"; int port = 22; String username = "your-username"; String password = "your-password"; SshClient client = SshClient.setUpDefaultClient(); client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE); client.start(); try (ClientSession session = client.connect(username, host, port).verify(3000).getSession()) { session.addPasswordIdentity(password); session.auth().verify(3000); SftpClient sftpClient = SftpClientFactory.instance().createSftpClient(session); //Sftp operation here } catch (IOException ex) { ex.printStackTrace(); throw new RuntimeException(ex); } finally { client.stop(); } } ``` Normally you should be able to connect to the server and run some sftp commands PS. If I use the virtual ethernet IP of my WSL distro it worked. ### Actual behavior ``` [main] INFO org.apache.sshd.common.io.DefaultIoServiceFactoryFactory - No detected/configured IoServiceFactoryFactory; using Nio2ServiceFactoryFactory [main] INFO org.apache.sshd.client.config.hosts.DefaultConfigFileHostEntryResolver - resolveEffectiveResolver(sftpuser@localhost:22/null) no configuration file at C:\Users\sftpuser\.ssh\config org.apache.sshd.common.SshException: DefaultConnectFuture[sftpuser@localhost/127.0.0.1:22]: Failed (IOException) to execute: The remote computer refused the network connection at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$2(AbstractSshFuture.java:146) at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:206) at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:145) at org.apache.sshd.client.future.DefaultConnectFuture.verify(DefaultConnectFuture.java:55) at org.apache.sshd.client.future.DefaultConnectFuture.verify(DefaultConnectFuture.java:36) at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:121) at org.chuck.App.main(App.java:29) Caused by: java.io.IOException: The remote computer refused the network connection at java.base/sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:299) at java.base/sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:389) at java.base/java.lang.Thread.run(Thread.java:840) Exception in thread "main" java.lang.RuntimeException: org.apache.sshd.common.SshException: DefaultConnectFuture[sftpuser@localhost/127.0.0.1:22]: Failed (IOException) to execute: The remote computer refused the network connection at org.chuck.App.main(App.java:39) Caused by: org.apache.sshd.common.SshException: DefaultConnectFuture[charles@localhost/127.0.0.1:2222]: Failed (IOException) to execute: The remote computer refused the network connection at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$2(AbstractSshFuture.java:146) at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:206) at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:145) at org.apache.sshd.client.future.DefaultConnectFuture.verify(DefaultConnectFuture.java:55) at org.apache.sshd.client.future.DefaultConnectFuture.verify(DefaultConnectFuture.java:36) at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:121) at org.chuck.App.main(App.java:29) Caused by: java.io.IOException: The remote computer refused the network connection at java.base/sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:299) at java.base/sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:389) at java.base/java.lang.Thread.run(Thread.java:840) Process finished with exit code 1 ``` Meaning that I cant connect, but if ### Expected behavior Normally it should find my sftp service ### Relevant log output ```Shell ``` ### 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