You can take advantage of the ability to restrict the key to a particular command using the command=
directive in authorized_keys and the SSH_ORIGINAL_COMMAND
variable that gets passed to the remote system.
In the authorized_keys file change the line containing the relevant key from
ssh-rsa AAAAB3NzaC1yc...
to
command="/path/to/myscript" ssh-rsa AAAAB3NzaC1yc...
Then create the myscript file like for example
#!/bin/bash
if [ ! -n "$SSH_ORIGINAL_COMMAND" ]
then
echo "No command supplied"
exit 1
fi
set $SSH_ORIGINAL_COMMAND
case "$1" in
ls)
;;
md5)
;;
*)
echo "invalid command"
exit 1
;;
esac
exec "$@"
so now if you run ssh [email protected] ls /etc
you'll get a listing of the remote /etc
directory. You'll probably want to use the case statements to test the supplied parameters to meet whatever your implementation requirements are.