title: Reuse connection from socket created by the OpenSSH client
body: <p>OpenSSH client has a feature called "ControlMaster" that allows to reuse connections between multiple ssh sessions over a single network connection.</p>
  
  <p>I was wondering if it was possible using <code>x/crypto/ssh</code> package of Golang to reuse a connection from a socket that has been created by the OpenSSH client with a command like:</p>
  
  <p><code>ssh -M -f -N -o ControlPath=$HOME/.ssh/shared.sock myUsername@targetServerName</code></p>
  
  <p>Is there any way to create a Golang Client from this <code>$HOME/.ssh/shared.sock</code> socket?</p>
  
  <p>We usually use the <code>Dial</code> function to create the Client.</p>
  
  <p><code>func Dial(network, addr string, config *ClientConfig) (*Client, error)</code></p>
  
  <p>But I see there is as well the <code>NewClient</code> function that seems to be for reusing an existing connection.</p>
  
  <p><code>func NewClient(c Conn, chans &lt;-chan NewChannel, reqs &lt;-chan *Request) *Client</code></p>
  
  <p>I struggle to understand how I can instantiate the <code>Conn</code> and the two channels in a proper way.</p>
  
  <p>Maybe it is not doable at all?</p>
  
  <p>The aim is to be able to implement a kind of wrapper of the OpenSSH client and trigger commands using Golang before/after calling the actual OpenSSH client process. It would as well avoid having to reimplement the target host/port logic and the authentication.</p>