You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Joerg Schmidbauer <JS...@de.ibm.com> on 2011/01/11 16:06:49 UTC

Question on SSHD

Hello development team!

I'm an IBM employee in Germany and I'm working in development
of the IBM System z mainframe operating system z/VSE.

http://www-03.ibm.com/systems/z/os/zvse/

I'm currently investigating the possibilities of implementing
SSH/SCP/SFTP for VSE. My favorite scenario would be some kind of
a "proxy SSHD" running on Unix/Linux/Windows, forwarding commands
via IP to VSE, where an already existing server executes cmds
and sends the output back.

Via Google I found the MINA Apache project and already tried some
things:

- I downloaded the apache-sshd-0.5.0 package
- I got it to run in Eclipse, i.e. I can start the SSHD
  and open a command shell via PUTTY.
- I found the place in org.apache.sshd.server.shell.ProcessImpl.java
  where the native shell (cmd.exe) is started.
- There I added some few code lines to submit a command to VSE and get
  its output back
- My hope was that I can just replace the native methods with my code
  and use the existing streams to write/read to/from VSE, but I'm getting
  an IOException.

At this point I'm now completely lost.

My question is basically: what's the simplest way of using the MINA SSHD
as a proxy with the VSE operating system? The most elegant way of course
would be just adding my code optionally without changing your code.

But I even do not know whether MINA would be ok for my approach at all.

Would be great to hear your opinion!


Mit freundlichen Grüßen / Kind regards

Joerg Schmidbauer
-----------------------------------------------------------------------------

z/VSE Development & Service 1
IBM Deutschland Research & Development GmbH
Dept. 3229, Schoenaicherstr. 220, 71032 Boeblingen
Phone: +49-7031-16-2998
-----------------------------------------------------------------------------

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart,
HRB 243294


RE: Question on SSHD

Posted by Frank van der Kleij <kl...@hotmail.com>.
The ScpCommand has already been refactored to use the filesystem abstraction; it is in the trunk...

Frank
> From: sop@google.com
> Date: Wed, 12 Jan 2011 08:07:01 -0800
> Subject: Re: Question on SSHD
> To: dev@mina.apache.org
> 
> On Tue, Jan 11, 2011 at 07:06, Joerg Schmidbauer <JS...@de.ibm.com> wrote:
> >
> > I'm currently investigating the possibilities of implementing
> > SSH/SCP/SFTP for VSE. My favorite scenario would be some kind of
> > a "proxy SSHD" running on Unix/Linux/Windows, forwarding commands
> > via IP to VSE, where an already existing server executes cmds
> > and sends the output back.
> ...
> > My question is basically: what's the simplest way of using the MINA SSHD
> > as a proxy with the VSE operating system? The most elegant way of course
> > would be just adding my code optionally without changing your code.
> 
> Create your own SshServer instance.  A good place to start is to use
> the setUpDefaultServer() method:
> 
>   SshServer sshd = SshServer.setUpDefaultServer();
> 
> Now replace the CommandFactory with your own.  This will handle any
> commands that come in from the command line and would forward them:
> 
>   sshd.setCommandFactory(new CommandFactory() {
>     public Command createCommand(String commandLine) {
>       return new VseCommand(commandLine);
>     }
>   });
> 
>   class VseCommand implements Command {
>     public void start(Environment env) {
>       ... create a new thread
>       ... within the thread, forward command to VSE
>       ... also do copying of InputStream, OutputStream, ErrorStream as necessary
>       ... note you may need 3 threads (one for each stream)
>     }
>   }
> 
> Likewise you can also replace the ShellFactory to support interactive
> shells, and FileSystemFactory to support the SFTP server's access to
> files.
> 
> scp is a bit more difficult.  Your CommandFactory would need to create
> and return the ScpCommand, but its file system interface hasn't been
> abstracted to use the FileSystemFactory.  So right now ScpCommand
> modifies the SshServer's host filesystem as the SshServer's JVM user.
> Not exactly what you want.  If you really need it, you should refactor
> ScpCommand to use the FileSystemFactory and try to submit the patch
> back to the project for inclusion in a future release.
 		 	   		  

Re: Question on SSHD

Posted by Shawn Pearce <so...@google.com>.
On Tue, Jan 11, 2011 at 07:06, Joerg Schmidbauer <JS...@de.ibm.com> wrote:
>
> I'm currently investigating the possibilities of implementing
> SSH/SCP/SFTP for VSE. My favorite scenario would be some kind of
> a "proxy SSHD" running on Unix/Linux/Windows, forwarding commands
> via IP to VSE, where an already existing server executes cmds
> and sends the output back.
...
> My question is basically: what's the simplest way of using the MINA SSHD
> as a proxy with the VSE operating system? The most elegant way of course
> would be just adding my code optionally without changing your code.

Create your own SshServer instance.  A good place to start is to use
the setUpDefaultServer() method:

  SshServer sshd = SshServer.setUpDefaultServer();

Now replace the CommandFactory with your own.  This will handle any
commands that come in from the command line and would forward them:

  sshd.setCommandFactory(new CommandFactory() {
    public Command createCommand(String commandLine) {
      return new VseCommand(commandLine);
    }
  });

  class VseCommand implements Command {
    public void start(Environment env) {
      ... create a new thread
      ... within the thread, forward command to VSE
      ... also do copying of InputStream, OutputStream, ErrorStream as necessary
      ... note you may need 3 threads (one for each stream)
    }
  }

Likewise you can also replace the ShellFactory to support interactive
shells, and FileSystemFactory to support the SFTP server's access to
files.

scp is a bit more difficult.  Your CommandFactory would need to create
and return the ScpCommand, but its file system interface hasn't been
abstracted to use the FileSystemFactory.  So right now ScpCommand
modifies the SshServer's host filesystem as the SshServer's JVM user.
Not exactly what you want.  If you really need it, you should refactor
ScpCommand to use the FileSystemFactory and try to submit the patch
back to the project for inclusion in a future release.