I configure a ssh command key like (in a remote mashine M1):
command="/usr/bin/nslookup",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss DEADBEEFDEADBEEF= [email protected]
To allow to run nslookup in M1 from a client machine C1. It works and i can run:
C1> ssh -i mylookup_key M1
And i get the nslookup execution on M1, but i need to pass parameters to get real work. How can i pass parameters to ssh command key?
p.d: I'm using nslookup as an example of the real program that I want to exec.
Take a look at the $SSH_ORIGINAL_COMMAND variable which should contain the command passed to ssh. For example:
command="/usr/bin/nslookup $SSH_ORIGINAL_COMMAND",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss DEADBEEFDEADBEEF= [email protected]
Then try:
$ ssh -i mylookup_key M1 stackoverflow.com
If I understand correctly you just want to run a command on the remote machine. The simple case is to just pass the command as the last parameter to ssh
ssh -i mylookup_key M1 nslookup stackoverflow.com
But you may need to be careful about quoting and special characters. e.g.
ssh -i mylookup_key M1 ./args.sh "1 2 3"
PROG:./args.sh
ARG[1]: 1
ARG[2]: 2
ARG[3]: 3
ssh -i mylookup_key M1 ./args.sh '"1 2 3"'
PROG:./args.sh
ARG[1]: 1 2 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With