LinuxCommandLibrary

ssh-argv0

Execute ssh command, preserving argv[0]

SYNOPSIS

ssh-argv0 command [arguments...]

PARAMETERS

command
    The command to execute.

[arguments...]
    Additional arguments to pass to the command.

DESCRIPTION

The ssh-argv0 command is a wrapper script primarily intended for use with OpenSSH's AuthorizedKeysCommand. It modifies the argv[0] of the command it executes. This is useful because the AuthorizedKeysCommand in OpenSSH does not provide a straightforward way to specify the argv[0] of the executed program. By default, it changes the first argument passed to the executed command to its base name from the PATH or a given path. It allows to use more complex configurations in OpenSSH authorized keys files or similar contexts where precise control over the executed command's environment is required.
Its main use case is situations where you want a specific command called through ssh to behave differently depending on how it's invoked.

CAVEATS

The script relies on the PATH variable being correctly set for the user executing the command. If the command is not found in the PATH, ssh-argv0 will likely fail. Also, ensure proper permissions are set on the script to prevent unauthorized access and modification.

EXAMPLE USAGE

If you have a script called my_script.sh and place it in a directory in your PATH (e.g., /usr/local/bin/) and want to call it with argv[0] set to 'my_script', you would use `ssh-argv0 my_script.sh`. The sshd server would then invoke 'my_script.sh', and inside the script, you can check the argv[0] variable to change the script's execution flow.

SEE ALSO

ssh(1), sshd(8), AuthorizedKeysCommand

Copied to clipboard