Class ProcessShellFactory

java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.shell.ProcessShellFactory
All Implemented Interfaces:
ShellFactory
Direct Known Subclasses:
InteractiveProcessShellFactory

public class ProcessShellFactory extends AbstractLoggingBean implements ShellFactory
A Factory of Command that will create a new process executing the given command in an OS shell.

Caveat: Apache MINA SSHD does not provide privilege separation, and SSH users are by default not tied to OS users. The OS shell will run as the same OS user the process using Apache MINA SSHD runs. The shell will have the same access rights as the Apache MINA SSHD server process itself.

It is in general not recommended to use this class as is in a production server.

  • Field Details

  • Constructor Details

    • ProcessShellFactory

      public ProcessShellFactory()
    • ProcessShellFactory

      public ProcessShellFactory(String command, String... elements)
    • ProcessShellFactory

      public ProcessShellFactory(String command, List<String> elements)
  • Method Details

    • getCommand

      public String getCommand()
      Returns:
      The original unparsed raw command
    • getElements

      public List<String> getElements()
      Returns:
      The parsed command elements
    • setCommand

      public void setCommand(String command, String... elements)
    • setCommand

      public void setCommand(String command, List<String> elements)
    • createShell

      public Command createShell(ChannelSession channel)
      Specified by:
      createShell in interface ShellFactory
      Parameters:
      channel - The ChannelSession through which the command has been received
      Returns:
      The Command representing the shell to be executed
    • createInvertedShell

      protected InvertedShell createInvertedShell(ChannelSession channel)
    • resolveEffectiveCommand

      protected List<String> resolveEffectiveCommand(ChannelSession channel, String rawCommand, List<String> parsedElements)
      Determines the shell command to run. On Windows cmd.exe /C is used; on other systems /bin/sh -c.
      Parameters:
      channel - ChannelSession the shell will be executed in
      rawCommand - the shell command passed
      parsedElements - legacy; unused
      Returns:
      a list containing the full command to run to execute the given rawCommand