You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Doron Fediuck <do...@redhat.com> on 2010/06/03 11:06:20 UTC

Server channel question

Hi,
I tried setting up a server using your 5-minute guide.
This server has-
sshd.setCommandFactory(new ScpCommandFactory());

The problem is, that my client code runs:
channel = session.createExecChannel("ls -l");

And this is not supported by ScpCommandFactory (took me a lot of
debug to get the error message "Unknown command, does not begin with 'scp'"
this has to be better logged!).

When my client code tuns on standard Linux sshd it works perfectly,
how can I support it with mina sshd server code without changing
the client side?

Thanks,
Doron

Re: Server channel question

Posted by Doron Fediuck <do...@redhat.com>.
Job well done!

On Thursday 03 June 2010 14:22:28 Guillaume Nodet wrote:
> Done, thx!
> See https://cwiki.apache.org/SSHD/tips.html
> 
> On Thu, Jun 3, 2010 at 12:01, Doron Fediuck <do...@redhat.com> wrote:
> > On Thursday 03 June 2010 12:40:51 Guillaume Nodet wrote:
> >> Right, but look at http://mina.apache.org/sshd/
> >> The second sentence of the web site is:
> >>     "SSHD does not really aim at being a replacement for the SSH
> >> client or SSH server from Unix operating systems, but rather provides
> >> support for Java based applications requiring SSH support."
> > I know that, and I think you're doing a great job!
> >
> >>
> >> That said, I agree we could provide a simple CommandFactory that would
> >> just run the underlying OS command out of the box.
> >>
> >> Maybe try something like:
> >>
> >>         sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
> >>             public Command createCommand(String command) {
> >>                 return new ProcessShellFactory(command.split(" ")).create();
> >>             }
> >>         }));
> > Works like a charm, which make you a magician :)
> > I suggest you add it to the docs, since it will be forgotten in the list.
> >
> > Thanks a lot !!!!
> >
> >>
> >>
> >> On Thu, Jun 3, 2010 at 11:25, Doron Fediuck <do...@redhat.com> wrote:
> >> > On Thursday 03 June 2010 12:14:01 Guillaume Nodet wrote:
> >> >> Not sure to completely understand your problem.
> >> >> When the client execute a remote command, you need the server to be
> >> >> able to understand and actually run the command.
> >> >> If you're sending "ls -l" you need something on the server to handle that.
> >> >> There is only a single CommandFactory implementation provided, which
> >> >> is the one for scp support.
> >> >> If you want to support "ls -l", you need to implement your own
> >> >> CommandFactory, which could either launch a process to run "ls -l"
> >> >> (and that would only work on unix) or implement it yourself the way
> >> >> you want.
> >> >> Not sure if that's only an example, or if you actually want to run "ls
> >> >> -l" though ...
> >> >
> >> > You're right- it's an example, and I wanted to know if there's an implementation
> >> > of shell CommandFactory ? It seems to be the case in standard Linux sshd.
> >> > IE- if I open an exec channel to a Linux based SSH server I can simply
> >> > run 'ls -l ' and get the response without the need to open a shell channel.
> >> >
> >> >>
> >> >> On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
> >> >> > Hi,
> >> >> > I tried setting up a server using your 5-minute guide.
> >> >> > This server has-
> >> >> > sshd.setCommandFactory(new ScpCommandFactory());
> >> >> >
> >> >> > The problem is, that my client code runs:
> >> >> > channel = session.createExecChannel("ls -l");
> >> >> >
> >> >> > And this is not supported by ScpCommandFactory (took me a lot of
> >> >> > debug to get the error message "Unknown command, does not begin with 'scp'"
> >> >> > this has to be better logged!).
> >> >> >
> >> >> > When my client code tuns on standard Linux sshd it works perfectly,
> >> >> > how can I support it with mina sshd server code without changing
> >> >> > the client side?
> >> >> >
> >> >> > Thanks,
> >> >> > Doron
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >>
> >>
> >>
> >
> 
> 
> 
> 

Re: Server channel question

Posted by Guillaume Nodet <gn...@gmail.com>.
Done, thx!
See https://cwiki.apache.org/SSHD/tips.html

On Thu, Jun 3, 2010 at 12:01, Doron Fediuck <do...@redhat.com> wrote:
> On Thursday 03 June 2010 12:40:51 Guillaume Nodet wrote:
>> Right, but look at http://mina.apache.org/sshd/
>> The second sentence of the web site is:
>>     "SSHD does not really aim at being a replacement for the SSH
>> client or SSH server from Unix operating systems, but rather provides
>> support for Java based applications requiring SSH support."
> I know that, and I think you're doing a great job!
>
>>
>> That said, I agree we could provide a simple CommandFactory that would
>> just run the underlying OS command out of the box.
>>
>> Maybe try something like:
>>
>>         sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
>>             public Command createCommand(String command) {
>>                 return new ProcessShellFactory(command.split(" ")).create();
>>             }
>>         }));
> Works like a charm, which make you a magician :)
> I suggest you add it to the docs, since it will be forgotten in the list.
>
> Thanks a lot !!!!
>
>>
>>
>> On Thu, Jun 3, 2010 at 11:25, Doron Fediuck <do...@redhat.com> wrote:
>> > On Thursday 03 June 2010 12:14:01 Guillaume Nodet wrote:
>> >> Not sure to completely understand your problem.
>> >> When the client execute a remote command, you need the server to be
>> >> able to understand and actually run the command.
>> >> If you're sending "ls -l" you need something on the server to handle that.
>> >> There is only a single CommandFactory implementation provided, which
>> >> is the one for scp support.
>> >> If you want to support "ls -l", you need to implement your own
>> >> CommandFactory, which could either launch a process to run "ls -l"
>> >> (and that would only work on unix) or implement it yourself the way
>> >> you want.
>> >> Not sure if that's only an example, or if you actually want to run "ls
>> >> -l" though ...
>> >
>> > You're right- it's an example, and I wanted to know if there's an implementation
>> > of shell CommandFactory ? It seems to be the case in standard Linux sshd.
>> > IE- if I open an exec channel to a Linux based SSH server I can simply
>> > run 'ls -l ' and get the response without the need to open a shell channel.
>> >
>> >>
>> >> On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
>> >> > Hi,
>> >> > I tried setting up a server using your 5-minute guide.
>> >> > This server has-
>> >> > sshd.setCommandFactory(new ScpCommandFactory());
>> >> >
>> >> > The problem is, that my client code runs:
>> >> > channel = session.createExecChannel("ls -l");
>> >> >
>> >> > And this is not supported by ScpCommandFactory (took me a lot of
>> >> > debug to get the error message "Unknown command, does not begin with 'scp'"
>> >> > this has to be better logged!).
>> >> >
>> >> > When my client code tuns on standard Linux sshd it works perfectly,
>> >> > how can I support it with mina sshd server code without changing
>> >> > the client side?
>> >> >
>> >> > Thanks,
>> >> > Doron
>> >> >
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>
>>
>>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Server channel question

Posted by Doron Fediuck <do...@redhat.com>.
On Thursday 03 June 2010 12:40:51 Guillaume Nodet wrote:
> Right, but look at http://mina.apache.org/sshd/
> The second sentence of the web site is:
>     "SSHD does not really aim at being a replacement for the SSH
> client or SSH server from Unix operating systems, but rather provides
> support for Java based applications requiring SSH support."
I know that, and I think you're doing a great job!

> 
> That said, I agree we could provide a simple CommandFactory that would
> just run the underlying OS command out of the box.
> 
> Maybe try something like:
> 
>         sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
>             public Command createCommand(String command) {
>                 return new ProcessShellFactory(command.split(" ")).create();
>             }
>         }));
Works like a charm, which make you a magician :)
I suggest you add it to the docs, since it will be forgotten in the list.

Thanks a lot !!!!

> 
> 
> On Thu, Jun 3, 2010 at 11:25, Doron Fediuck <do...@redhat.com> wrote:
> > On Thursday 03 June 2010 12:14:01 Guillaume Nodet wrote:
> >> Not sure to completely understand your problem.
> >> When the client execute a remote command, you need the server to be
> >> able to understand and actually run the command.
> >> If you're sending "ls -l" you need something on the server to handle that.
> >> There is only a single CommandFactory implementation provided, which
> >> is the one for scp support.
> >> If you want to support "ls -l", you need to implement your own
> >> CommandFactory, which could either launch a process to run "ls -l"
> >> (and that would only work on unix) or implement it yourself the way
> >> you want.
> >> Not sure if that's only an example, or if you actually want to run "ls
> >> -l" though ...
> >
> > You're right- it's an example, and I wanted to know if there's an implementation
> > of shell CommandFactory ? It seems to be the case in standard Linux sshd.
> > IE- if I open an exec channel to a Linux based SSH server I can simply
> > run 'ls -l ' and get the response without the need to open a shell channel.
> >
> >>
> >> On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
> >> > Hi,
> >> > I tried setting up a server using your 5-minute guide.
> >> > This server has-
> >> > sshd.setCommandFactory(new ScpCommandFactory());
> >> >
> >> > The problem is, that my client code runs:
> >> > channel = session.createExecChannel("ls -l");
> >> >
> >> > And this is not supported by ScpCommandFactory (took me a lot of
> >> > debug to get the error message "Unknown command, does not begin with 'scp'"
> >> > this has to be better logged!).
> >> >
> >> > When my client code tuns on standard Linux sshd it works perfectly,
> >> > how can I support it with mina sshd server code without changing
> >> > the client side?
> >> >
> >> > Thanks,
> >> > Doron
> >> >
> >>
> >>
> >>
> >>
> >
> 
> 
> 
> 

Re: Server channel question

Posted by Guillaume Nodet <gn...@gmail.com>.
Right, but look at http://mina.apache.org/sshd/
The second sentence of the web site is:
    "SSHD does not really aim at being a replacement for the SSH
client or SSH server from Unix operating systems, but rather provides
support for Java based applications requiring SSH support."

That said, I agree we could provide a simple CommandFactory that would
just run the underlying OS command out of the box.

Maybe try something like:

        sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
            public Command createCommand(String command) {
                return new ProcessShellFactory(command.split(" ")).create();
            }
        }));


On Thu, Jun 3, 2010 at 11:25, Doron Fediuck <do...@redhat.com> wrote:
> On Thursday 03 June 2010 12:14:01 Guillaume Nodet wrote:
>> Not sure to completely understand your problem.
>> When the client execute a remote command, you need the server to be
>> able to understand and actually run the command.
>> If you're sending "ls -l" you need something on the server to handle that.
>> There is only a single CommandFactory implementation provided, which
>> is the one for scp support.
>> If you want to support "ls -l", you need to implement your own
>> CommandFactory, which could either launch a process to run "ls -l"
>> (and that would only work on unix) or implement it yourself the way
>> you want.
>> Not sure if that's only an example, or if you actually want to run "ls
>> -l" though ...
>
> You're right- it's an example, and I wanted to know if there's an implementation
> of shell CommandFactory ? It seems to be the case in standard Linux sshd.
> IE- if I open an exec channel to a Linux based SSH server I can simply
> run 'ls -l ' and get the response without the need to open a shell channel.
>
>>
>> On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
>> > Hi,
>> > I tried setting up a server using your 5-minute guide.
>> > This server has-
>> > sshd.setCommandFactory(new ScpCommandFactory());
>> >
>> > The problem is, that my client code runs:
>> > channel = session.createExecChannel("ls -l");
>> >
>> > And this is not supported by ScpCommandFactory (took me a lot of
>> > debug to get the error message "Unknown command, does not begin with 'scp'"
>> > this has to be better logged!).
>> >
>> > When my client code tuns on standard Linux sshd it works perfectly,
>> > how can I support it with mina sshd server code without changing
>> > the client side?
>> >
>> > Thanks,
>> > Doron
>> >
>>
>>
>>
>>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Server channel question

Posted by Doron Fediuck <do...@redhat.com>.
On Thursday 03 June 2010 12:14:01 Guillaume Nodet wrote:
> Not sure to completely understand your problem.
> When the client execute a remote command, you need the server to be
> able to understand and actually run the command.
> If you're sending "ls -l" you need something on the server to handle that.
> There is only a single CommandFactory implementation provided, which
> is the one for scp support.
> If you want to support "ls -l", you need to implement your own
> CommandFactory, which could either launch a process to run "ls -l"
> (and that would only work on unix) or implement it yourself the way
> you want.
> Not sure if that's only an example, or if you actually want to run "ls
> -l" though ...

You're right- it's an example, and I wanted to know if there's an implementation
of shell CommandFactory ? It seems to be the case in standard Linux sshd.
IE- if I open an exec channel to a Linux based SSH server I can simply
run 'ls -l ' and get the response without the need to open a shell channel.

> 
> On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
> > Hi,
> > I tried setting up a server using your 5-minute guide.
> > This server has-
> > sshd.setCommandFactory(new ScpCommandFactory());
> >
> > The problem is, that my client code runs:
> > channel = session.createExecChannel("ls -l");
> >
> > And this is not supported by ScpCommandFactory (took me a lot of
> > debug to get the error message "Unknown command, does not begin with 'scp'"
> > this has to be better logged!).
> >
> > When my client code tuns on standard Linux sshd it works perfectly,
> > how can I support it with mina sshd server code without changing
> > the client side?
> >
> > Thanks,
> > Doron
> >
> 
> 
> 
> 

Re: Server channel question

Posted by Guillaume Nodet <gn...@gmail.com>.
Not sure to completely understand your problem.
When the client execute a remote command, you need the server to be
able to understand and actually run the command.
If you're sending "ls -l" you need something on the server to handle that.
There is only a single CommandFactory implementation provided, which
is the one for scp support.
If you want to support "ls -l", you need to implement your own
CommandFactory, which could either launch a process to run "ls -l"
(and that would only work on unix) or implement it yourself the way
you want.
Not sure if that's only an example, or if you actually want to run "ls
-l" though ...

On Thu, Jun 3, 2010 at 11:06, Doron Fediuck <do...@redhat.com> wrote:
> Hi,
> I tried setting up a server using your 5-minute guide.
> This server has-
> sshd.setCommandFactory(new ScpCommandFactory());
>
> The problem is, that my client code runs:
> channel = session.createExecChannel("ls -l");
>
> And this is not supported by ScpCommandFactory (took me a lot of
> debug to get the error message "Unknown command, does not begin with 'scp'"
> this has to be better logged!).
>
> When my client code tuns on standard Linux sshd it works perfectly,
> how can I support it with mina sshd server code without changing
> the client side?
>
> Thanks,
> Doron
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com