Search code examples
shellunixsshopenssh

Passing parameters to a SSH client to execute a ForceCommand with parameters


I'm having trouble passing command parameters remotely to a "ForceCommand" program in ssh.

In my remote server I have this configuration in sshd_config:

Match User user_1 
ForceCommand /home/user_1/user_1_shell

The user_1_shell program limits the commands the user can execute, in this case, I only allow the user to execute "set_new_mode param1 param2". Any other commands will be ignored.

So I expect that when a client logs in via ssh such as this one:

ssh user_1@remotehost "set_new_mode param1 param2"

The user_1_shell program seems to be executed, but the parameter string doesn't seem to be passed.

Maybe, I should be asking, does ForceCommand actually support this? If yes, any suggestions on how I could make it work?

Thanks.


Solution

  • I found the answer. The remote server captures the parameter string and saves it in "$SSH_ORIGINAL_COMMAND" environment variable.