You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "yuhJohn (via GitHub)" <gi...@apache.org> on 2026/05/18 06:45:21 UTC

[I] The ProcessShellCommandFactory does not support ssh-copy-id and multi-command execution. [mina-sshd]

yuhJohn opened a new issue, #899:
URL: https://github.com/apache/mina-sshd/issues/899

   Question 1: 
   The  ssh-copy-id  command is not supported. This is actually a standard command for ssh.
   clientInput:
   `ssh-copy-id -p 123 -i /root/.ssh/id_rsa.pub  user@ip`
   
    and received  the following command
   `exec sh -c'cd; umask 077; mkdir -p \".ssh\" && {[-z `tail -1c .ssh/authorized_keys 2>/dev/null`] || echo >> \".ssh/authorized_keys\" || exit 1;} && cat >> \".ssh/authorized_keys\" || exit 1; if type restorecon >/dev/null 2>&1; then restorecon -F \".ssh\" \".ssh/authorized_keys\"; fi'`
   
   The exec cannot be identified. As a result, the execution fails.
   I solved this by customizing exec judgment.
   ```
       public Command createCommand(ChannelSession channel, String command) throws IOException {
   
           LOGGER.error("create Command: " + command);
   
           if (command !=null && command.startsWith("exec ")) {
               command = command.substring(5);
           }
   
           return new ShellWrapperCommand(command);
   }
   ```
   
   
   Question 2: Multiple commands such as " ls -l; rm -rf /tmp/test" cannot be executed correctly.
   The input is as follows:
   `ssh user@IP -p 123 "echo test2; echo 22"`
   
   The actual output is
   `test2; echo 22`
   
   I understand that the preceding two questions are very common scenarios. Is SSHD not supported by default?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [I] The ProcessShellCommandFactory does not support ssh-copy-id and multi-command execution. [mina-sshd]

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf closed issue #899: The ProcessShellCommandFactory does not support ssh-copy-id and multi-command execution.
URL: https://github.com/apache/mina-sshd/issues/899


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [I] The ProcessShellCommandFactory does not support ssh-copy-id and multi-command execution. [mina-sshd]

Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on issue #899:
URL: https://github.com/apache/mina-sshd/issues/899#issuecomment-4502338553

   Looking at this `ProcessShellFactory` code I must say I think this is simply wrong on Linux systems. It tries to run the command directly, but it should actually start a shell and make that shell execute the given command.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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