You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "ashishkumar2804 (via GitHub)" <gi...@apache.org> on 2023/03/21 05:35:13 UTC

[GitHub] [mina-sshd] ashishkumar2804 opened a new issue, #340: Getting error while connecting to embedded server using sshclient in Authentication

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

   I am getting below error while connecting to embedded server using sshclient 
   Server at localhost/127.0.0.1:2222 presented wrong key:
   
   Code to create embedded server
   `m_sshServer = SshServer.setUpDefaultServer();
           m_sshServer.setHost("localhost");
           m_sshServer.setPort(m_sftpPort);
           m_sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(m_serverKeyPath));
           m_sshServer.setSubsystemFactories(getSftpSubsystemFactory());
           m_sshServer.setUserAuthFactories(getUserAuthFactory());
           m_sshServer.setPasswordAuthenticator(new SimplePasswordAuthenticator());
           m_sshServer.setFileSystemFactory(createVirtualFileSystemFactory());
           m_sshServer.start();
   `
   
   Code to connect using sshClient
   `SshClient sshClient = SshClient.setUpDefaultClient();
   sshClient.setServerKeyVerifier(new RequiredServerKeyVerifier(hostPublicKey));
   sshClient.start();
   connectFuture = m_sshClient.connect(m_config.getUserName(), m_config.getHostName(), m_config.getPort())
                       .verify((long)(m_config.getConnectionTimeoutSeconds() * MILLIS_PER_SECOND));
   clientSession = connectFuture.getClientSession();
   clientSession.addPasswordIdentity(m_config.getPassword());
               authFuture = clientSession.auth()
                       .verify((long)(m_config.getConnectionTimeoutSeconds() * MILLIS_PER_SECOND));
   `
   
   I am not sure, what I am missing, or where I am going wrong.


-- 
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-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf commented on issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #340:
URL: https://github.com/apache/mina-sshd/issues/340#issuecomment-1478431583

   Your client requires the server to have a particular host key matching `hostPublicKey`. Your server uses a `SimpleGeneratorHostKeyProvider`. Double-check that the server does use the expected host key.


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf closed issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf closed issue #340: Getting error while connecting to embedded server using sshclient in Authentication
URL: https://github.com/apache/mina-sshd/issues/340


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] ashishkumar2804 commented on issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "ashishkumar2804 (via GitHub)" <gi...@apache.org>.
ashishkumar2804 commented on issue #340:
URL: https://github.com/apache/mina-sshd/issues/340#issuecomment-1480654212

   Bu debugging as above, found that while setting server keypair, it is taking default Algorithm as EC, which was causing the issue. Fixed that, but now i am not able to connect to server by creating SFTP Client using the clientSession. Below is the code i have used to connect
   `m_internalSftpClient = SftpClientFactory.instance().createSftpClient(m_clientSession);`
   
   The logs, which i see is as below
   `2023-03-23T06:03:22,906Z app=mpgs resource=EmbeddedSftpServer INFO  [thread_id=1] Starting up embedded SFTP server.
   2023-03-23T06:03:23,380Z app=mpgs resource=EmbeddedSftpServer INFO  [thread_id=1] Embedded SFTP server started successfully
   2023-03-23T06:03:24,109Z app=mpgs resource=ServerSessionImpl INFO  [thread_id=56] Session sftp@/127.0.0.1:62271 authenticated
   Caused by: org.apache.sshd.common.SshException: DefaultOpenFuture[SftpChannelSubsystem[id=0, recipient=-1]-ClientSessionImpl[sftp@localhost/127.0.0.1:2222][sftp]]: Failed
   `
   
   What i am confused is at the port address, i had provided port 2222, while creating the server, also while creating the sshClient. But while authenticating, it is showing be different port which was used for the purpose.
   


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf commented on issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #340:
URL: https://github.com/apache/mina-sshd/issues/340#issuecomment-1480181484

   Set a debug breakpoint in the client inside `RequiredServerKeyVerifier.verifyServerKey()` and check what the host key you get is. If it's not the one you expect, set a breakpoint in the server in the `SimpleGeneratorHostKeyProvider` and check what happens there.


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] ashishkumar2804 commented on issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "ashishkumar2804 (via GitHub)" <gi...@apache.org>.
ashishkumar2804 commented on issue #340:
URL: https://github.com/apache/mina-sshd/issues/340#issuecomment-1478796143

   And how do I ensure that? The same code was working with sshd-core version 0.12. We are trying to migrate to version 2.9.2. With the new version is there any different method to set public key at client side to match with server key-pair?


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org


[GitHub] [mina-sshd] tomaswolf commented on issue #340: Getting error while connecting to embedded server using sshclient in Authentication

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #340:
URL: https://github.com/apache/mina-sshd/issues/340#issuecomment-1483868786

   The server listens on port 2222. The client logs that port, since that is what it connects _to_. But the server logs the client-side port the client is connecting _from_, which is 62271 in this case.
   
   I can't debug your code, and I can't make sense of your log excerpt. You will have to debug this yourself. Maybe look at some of the SFTP tests in sshd-sftp to see how an SFTP server and client can be set up.


-- 
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-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org