You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by GitBox <gi...@apache.org> on 2019/05/24 06:32:15 UTC

[GitHub] [mina-sshd] fengjian1993 opened a new pull request #103: [1.1.x]question about use mina-sshd as ssh-client and send shell command

fengjian1993 opened a new pull request #103: [1.1.x]question about use mina-sshd as ssh-client and send shell command
URL: https://github.com/apache/mina-sshd/pull/103
 
 
          SshClient client = SshClient.setUpDefaultClient();
           client.start();
           ConnectFuture connect = client.connect("zmc", "10.45.5.246", 22);
           if (connect.await(5000L)) {
               ClientSession session = connect.getSession();
               session.addPasswordIdentity("zmc");
               session.auth().verify(5000L);
               ChannelShell channel = (ChannelShell) session.createChannel(ClientChannel.CHANNEL_SHELL);
               channel.setIn(new NoCloseInputStream(System.in));
               channel.setOut(new NoCloseOutputStream(System.out));
               channel.setErr(new NoCloseOutputStream(System.err));
               channel.open();
               System.out.println(channel.getProperties());
               channel.waitFor(Arrays.asList(ClientChannelEvent.CLOSED), 0);
               session.close(false);
               client.stop();
   I have sent via console successfully. i want to ask how to sent via java command?
   Thanks.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services