I try to send command via ssh which looks like this:
ssh [email protected] "echo $(uname -a)"
But my problem is, that $(uname -a)
part actually create a subshell and executes not on 192.168.1.1 server, but on my system, from which I executed this command.
How can I fix it?
P.S. My actual example involved docker stop all command, which looks like
docker stop $(docker ps -q)
but I simplified question.
UPDATED: Sorry, I oversimplify my question. My command use Here Document (because inside command is complex and use a lot of different quotes marks)
ssh [email protected] <<SSHCOMMAND
echo $(uname -a)
SSHCOMMAND
So Ignacio Vazquez-Abrams solution will not work