The ScpCommand has already been refactored to use the filesystem abstraction; it is in the trunk...
Frank > From: [email protected] > Date: Wed, 12 Jan 2011 08:07:01 -0800 > Subject: Re: Question on SSHD > To: [email protected] > > On Tue, Jan 11, 2011 at 07:06, Joerg Schmidbauer <[email protected]> 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.
