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

[I] When using SSH client, the server has no output [mina-sshd]

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

   ### Version
   
   2.11.0
   
   ### Bug description
   
   ```java
   package cn.dyw.web.jshell.client;
   
   import org.apache.sshd.client.SshClient;
   import org.apache.sshd.client.channel.ClientChannel;
   import org.apache.sshd.client.channel.ClientChannelEvent;
   import org.apache.sshd.client.future.ConnectFuture;
   import org.apache.sshd.client.session.ClientSession;
   import org.apache.sshd.common.future.CancelOption;
   import org.apache.sshd.common.util.io.input.NoCloseInputStream;
   import org.apache.sshd.common.util.io.output.NoCloseOutputStream;
   import org.junit.jupiter.api.Test;
   
   import java.net.InetSocketAddress;
   import java.util.Collections;
   import java.util.concurrent.TimeUnit;
   
   /**
    * @author dyw770
    * @date 2023-11-27
    */
   
   public class SSHDClientTest {
   
       /**
        * Server has no output
        */
       @Test
       public void testSSHDClient() throws Exception {
           SshClient client = SshClient.setUpDefaultClient();
           client.start();
           ConnectFuture connectFuture = client.connect("root", new InetSocketAddress("172.16.253.101", 22));
           ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT).getSession();
           session.addPasswordIdentity("123456789");
           session.auth().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT);
           ClientChannel channel =session.createShellChannel();
           channel.setOut(new NoCloseOutputStream(System.out));
           channel.setRedirectErrorStream(true);
           channel.setIn(new NoCloseInputStream(System.in));
           channel.open().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT);
   
           channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0);
           channel.close();
           session.close();
           client.stop();
       }
   
       /**
        * Normal server output
        */
       public static void main(String[] args) throws Exception {
           SshClient client = SshClient.setUpDefaultClient();
           client.start();
           ConnectFuture connectFuture = client.connect("root", new InetSocketAddress("172.16.253.101", 22));
           ClientSession session = connectFuture.verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT).getSession();
           session.addPasswordIdentity("123456789");
           session.auth().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT);
           ClientChannel channel =session.createShellChannel();
           channel.setOut(new NoCloseOutputStream(System.out));
           channel.setRedirectErrorStream(true);
           channel.setIn(new NoCloseInputStream(System.in));
           channel.open().verify(1000, TimeUnit.SECONDS, CancelOption.CANCEL_ON_TIMEOUT);
   
           channel.waitFor(Collections.singleton(ClientChannelEvent.CLOSED), 0);
           channel.close();
           session.close();
           client.stop();
       }
   
   }
   
   ```
   The result is shown in the figure
   <img width="2418" alt="image" src="https://github.com/apache/mina-sshd/assets/26217571/2085b364-d3c4-450b-b632-c04676f7c8c6">
   <img width="2453" alt="image" src="https://github.com/apache/mina-sshd/assets/26217571/4426c3fa-0849-4e3f-afbc-7ef097ab242b">
   
   Can you tell me where my mistake lies? 
   Thinks.
   
   ### Actual behavior
   
   Server has no output
   
   ### Expected behavior
   
   Normal server output
   
   ### 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-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


Re: [I] When using SSH client, the server has no output [mina-sshd]

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

   > Cannot reproduce. Using your code on OS X with two minor modifications:
   > 
   > 1. Connect to my own user on localhost port 22.
   > 2. Use public-key authentication instead of password authentication.
   > 
   > Both running `main` or running the unit test work, `ls` or `ls -l` do show the expected output.
   
   Thank, I think I need to check my ide.


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


Re: [I] When using SSH client, the server has no output [mina-sshd]

Posted by "dyw770 (via GitHub)" <gi...@apache.org>.
dyw770 closed issue #441: When using SSH client, the server has no output
URL: https://github.com/apache/mina-sshd/issues/441


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


Re: [I] When using SSH client, the server has no output [mina-sshd]

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

   Cannot reproduce. Using your code on OS X with two minor modifications:
   
   1. Connect to my own user on localhost port 22.
   2. Use public-key authentication instead of password authentication.
   
   Both running `main` or running the unit test work, `ls` or `ls -l` do show the expected output.


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


Re: [I] When using SSH client, the server has no output [mina-sshd]

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

   Idea needs to add `- Editable. Java. test. console=true` options
   
   


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