title: How to specify the private SSH-key to use when executing shell command on Git?
body: <p>A rather unusual situation perhaps, but I want to specify a private SSH-key to use when executing a shell (<code>git</code>) command from the local computer.</p>
  <p>Basically like this:</p>
  <pre><code>git clone git@github.com:TheUser/TheProject.git -key &quot;/home/christoffer/ssh_keys/theuser&quot;
  </code></pre>
  <p>Or even better (in Ruby):</p>
  <pre><code>with_key(&quot;/home/christoffer/ssh_keys/theuser&quot;) do
    sh(&quot;git clone git@github.com:TheUser/TheProject.git&quot;)
  end
  </code></pre>
  <p>I have seen examples of connecting to a remote server with <code>Net::SSH</code> that uses a specified private key, but this is a local command. Is it possible?</p>