title: Libgit2 : SSH : Unable to exchange encryption keys
body: <h1>Background</h1>
  <p>I'm writing a Linux based application (gtkmm) that uses a single private repository hosted on github.  The application is using <code>Libgit2</code> and <code>SSH Authentication</code>.
  The SSH Keys were created externally, and work fine when tested via a terminal.</p>
  <p>I currently have two issues that more than likely correlate.</p>
  <h2>Issue 1: Unable to Exchange Encryption Keys.</h2>
  <p>This issue occurs when attempting to clone the private repository; and is the error printed from Libgit2.
  I've attempted to use <code>git_cred_ssh_key_new</code> AND <code>git_cred_ssh_key_from_agent</code> without success.</p>
  <h2>Issue 2: The Credential Callback is never called.</h2>
  <p>I've ensured that this (<code>Credential</code> callback) has been set for clone options, fetch options, and remote callbacks; and is being used by the <code>git_clone()</code>.
  A cout is inside this that is never printed; as is a GUI related text which is also not set; so I've determined this is never being called.</p>
  <pre class="lang-cpp prettyprint-override"><code>int repoManager_gitCredentialCallback(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload){
  cout &lt;&lt; &quot;Credentials Called&quot; &lt;&lt; endl;
  string temp_publicKey = Global::programHomeDir + &quot;/id_rsa.pub&quot;;
  string temp_privateKey = Global::programHomeDir + &quot;/id_rsa&quot;;
  return git_cred_ssh_key_new( out, username_from_url, temp_publicKey.c_str(), temp_privateKey.c_str(), &quot;&quot; );
  } // END - gitCredentialCallback
  </code></pre>
  <p>In function for cloning:</p>
  <pre><code>// SET GIT OPTIONS:
  git_clone_options repoManager_cloneOptions = GIT_CLONE_OPTIONS_INIT;
  git_fetch_options repoManager_fetchOptions = GIT_FETCH_OPTIONS_INIT;
  //  git_remote_callbacks repoManager_remoteCallbacks = GIT_REMOTE_CALLBACKS_INIT;
      
  repoManager_cloneOptions.fetch_opts.callbacks.credentials = repoManager_gitCredentialCallback;
  repoManager_cloneOptions.fetch_opts.callbacks.transfer_progress = repoManager_fetchProgress;
  repoManager_cloneOptions.fetch_opts.callbacks.payload = this;
  repoManager_cloneOptions.remote_cb = repoManager_gitRemoteCallback;
  
  //  repoManager_remoteCallbacks.credentials = repoManager_gitCredentialCallback;
  //  repoManager_cloneOptions.fetch_opts = repoManager_fetchOptions;
  
  repoManager_fetchOptions.callbacks.transfer_progress = repoManager_fetchProgress;
  repoManager_fetchOptions.callbacks.credentials = repoManager_gitCredentialCallback;
  repoManager_fetchOptions.callbacks.payload = this;
  repoManager_fetchOptions.download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
  
  
  if(git_clone(&amp;repoManager_repo, repoManager_RepoURL, Global::launcherRepositoryDir.c_str(), &amp;repoManager_cloneOptions) &lt; 0){
      RepoManager_thread_taskFailed(&quot;Failed to Clone the repository.&quot;, &quot;FAIL: Clone failed.&quot;);
      return;
  } // END - Git Clone
  </code></pre>