#!/usr/bin/perl -wT # BEGIN { delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; $ENV{PATH} = ""; } use strict; process_ssh_command($ENV{SSH_ORIGINAL_COMMAND}); exit; sub process_ssh_command { my $ssh_command = shift || ''; if ( ! $ssh_command ){ print "Error: You must specify the command to run\n"; return; } if ( $ssh_command =~ /^scriptname\s+(options_regex)$/ ){ my $options= $1 || ''; # do something if options not set chomp(my $stdin = ); # if you need it # untaint stdin system("/path/to/scriptname", $options); return; } print "Error: Unknown command or incorrect format \"$ssh_command\"\n"; return; }