You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Prajwal M <pr...@oracle.com> on 2019/10/16 15:42:05 UTC

Using MINA sshd 2.2.0

Hi All,

I am currently trying to migrate from JSCH to MINA sshd api's

Can you guys please let me know if there is any documentation about how 
to migrate to MINA (mapping jsch to MINA api's)


As of now I am trying to execute a simple command /bin/uname and get its 
out put

as below

  try (ChannelExec channel = session.createExecChannel(command)){
   Trace.out("opening the exec channel");
               channel.open().awaitUninterruptibly();
//channel.setStreaming(ClientChannel.Streaming.Sync);
               Trace.out("Streaming : " + 
channel.getStreaming().toString());

                InputStream in = channel.getInvertedOut(); 
<------------------------------------ get some object for which buffer 
is never ready
                InputStreamReader inStream = new InputStreamReader(in);
              BufferedReader bufReader = new BufferedReader (inStream);
                 boolean isBufReady = bufReader.ready(); 
<----------------------------------------- buffer is never ready
                if (isBufReady)
                     {
                        thisLine = bufReader.readLine();
                        if ((thisLine != null) && (!"".equals(thisLine)))
                           Trace.out ("read line is " + thisLine);
                           }

               }


But I am unable to get the output in any of the streams getInvertedOut 
and getIn

getIn always returns null


The purpose here is that we should be able to handle the cases

1] normal command execution and get the output

2] If the command propmts for a password we should be able to write it 
and then get the output.

3] execute with key based authentication.


Please throw dome light on how to handle the Input and output streams 
while using the MINSA sshd API's

Speedy response would be appreciated.

Thanks

Prajwal


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


Re: Using MINA sshd 2.2.0

Posted by Vijay Shanker Dubey <vs...@codesode.com>.
Hi Prajwal,

Did you see and try something like this?

https://mina.apache.org/sshd-project/tips.html

---
*Thanks & Regards*,
Vijay Shanker |*Software Architect*


On Wed, Oct 16, 2019 at 9:15 PM Prajwal M <pr...@oracle.com> wrote:

> Hi All,
>
> I am currently trying to migrate from JSCH to MINA sshd api's
>
> Can you guys please let me know if there is any documentation about how
> to migrate to MINA (mapping jsch to MINA api's)
>
>
> As of now I am trying to execute a simple command /bin/uname and get its
> out put
>
> as below
>
>   try (ChannelExec channel = session.createExecChannel(command)){
>    Trace.out("opening the exec channel");
>                channel.open().awaitUninterruptibly();
> //channel.setStreaming(ClientChannel.Streaming.Sync);
>                Trace.out("Streaming : " +
> channel.getStreaming().toString());
>
>                 InputStream in = channel.getInvertedOut();
> <------------------------------------ get some object for which buffer
> is never ready
>                 InputStreamReader inStream = new InputStreamReader(in);
>               BufferedReader bufReader = new BufferedReader (inStream);
>                  boolean isBufReady = bufReader.ready();
> <----------------------------------------- buffer is never ready
>                 if (isBufReady)
>                      {
>                         thisLine = bufReader.readLine();
>                         if ((thisLine != null) && (!"".equals(thisLine)))
>                            Trace.out ("read line is " + thisLine);
>                            }
>
>                }
>
>
> But I am unable to get the output in any of the streams getInvertedOut
> and getIn
>
> getIn always returns null
>
>
> The purpose here is that we should be able to handle the cases
>
> 1] normal command execution and get the output
>
> 2] If the command propmts for a password we should be able to write it
> and then get the output.
>
> 3] execute with key based authentication.
>
>
> Please throw dome light on how to handle the Input and output streams
> while using the MINSA sshd API's
>
> Speedy response would be appreciated.
>
> Thanks
>
> Prajwal
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
> For additional commands, e-mail: dev-help@mina.apache.org
>
>

Re: Using MINA sshd 2.2.0

Posted by Prajwal M <pr...@oracle.com>.
Hi All,


I have a diferent problem now

I want to use the scpclient tp upload and download files

Is there a way to upload and download as a different user

e.g connect as user A and upload as user B using different passwords

Please let me know

Thanks

Prajwal


On 10/16/2019 9:12 PM, Prajwal M wrote:
> Hi All,
>
> I am currently trying to migrate from JSCH to MINA sshd api's
>
> Can you guys please let me know if there is any documentation about 
> how to migrate to MINA (mapping jsch to MINA api's)
>
>
> As of now I am trying to execute a simple command /bin/uname and get 
> its out put
>
> as below
>
>  try (ChannelExec channel = session.createExecChannel(command)){
>   Trace.out("opening the exec channel");
>               channel.open().awaitUninterruptibly();
> //channel.setStreaming(ClientChannel.Streaming.Sync);
>               Trace.out("Streaming : " + 
> channel.getStreaming().toString());
>
>                InputStream in = channel.getInvertedOut(); 
> <------------------------------------ get some object for which buffer 
> is never ready
>                InputStreamReader inStream = new InputStreamReader(in);
>              BufferedReader bufReader = new BufferedReader (inStream);
>                 boolean isBufReady = bufReader.ready(); 
> <----------------------------------------- buffer is never ready
>                if (isBufReady)
>                     {
>                        thisLine = bufReader.readLine();
>                        if ((thisLine != null) && (!"".equals(thisLine)))
>                           Trace.out ("read line is " + thisLine);
>                           }
>
>               }
>
>
> But I am unable to get the output in any of the streams getInvertedOut 
> and getIn
>
> getIn always returns null
>
>
> The purpose here is that we should be able to handle the cases
>
> 1] normal command execution and get the output
>
> 2] If the command propmts for a password we should be able to write it 
> and then get the output.
>
> 3] execute with key based authentication.
>
>
> Please throw dome light on how to handle the Input and output streams 
> while using the MINSA sshd API's
>
> Speedy response would be appreciated.
>
> Thanks
>
> Prajwal
>

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