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