I am looking for best way to call remote command over SSH. I create user 'rpcall', generate new certificate and fill authorized_keys. Secure it little bit more with
from="ip",no-agent-forwarding,no-X11-forwarding,no-port-forwarding,no-pty ssh-rsa ......
now user rpcall can't login to terminal
ssh -l rpc 192.168.12.1
PTY allocation request failed on channel 0
but it is possible to run any command
ssh -l rpc 192.168.12.1 cat /etc/passwd
Is there any solution i can limit command execution only to one processing script? For example /home/rpcall/bin/command.sh
I setuped bash shell for this user and using .bashrc force run processing script, but i don't know how to pass parameters from ssh call.
.bashrc for user rpcall
/home/rpcall/bin/command.sh $params1 $params2
exit
ssh call from other machine
ssh -l rpcall 192.168.12.1 "param1" "param2"
You can restrict commands using the authorized_keys file. Put
command="/home/rpcall/bin/command.sh"
before the key, in the authorized_keys file, and the user will only ever run that command when they connect.Check the man page for authorized_keys, this is from that man page,
If you need more than one command, you need to basically set up several sets of keys and use different keys to give you different commands.
Edit: I just noticed, the original command is available in the
SSH_ORIGINAL_COMMAND
environment variable, so you could indeed handle that input using your own script, doing something clever.