title: How to push to gitlab with java api with ssh
body: <p>I am using gitlab of version GitLab Community Edition 9.1.1 d3123f6.</p>
  <p>I am able to push my code to gitlab with http protocol but when I am trying with git protocol it is showing following error.</p>
  <pre><code>Exception in thread &quot;main&quot; 
  org.eclipse.jgit.errors.UnsupportedCredentialItem: 
  ssh://git@192......: 
  org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity 
  of host '192......' can't be established.
  
  RSA key fingerprint is 
  99:...............
  Are you sure you want to continue connecting?
  at org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:119)
  at org.eclipse.jgit.transport.CredentialsProviderUserInfo.promptYesNo(CredentialsProviderUserInfo.java:124)
  at com.jcraft.jsch.Session.checkHost(Session.java:785)
  at com.jcraft.jsch.Session.connect(Session.java:342)
  at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:117)
  at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:137)
  at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.&lt;init&gt;(TransportGitSsh.java:264)
  at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:162)
  at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
  at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
  at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1201)
  at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
  at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:203)
  at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:136)
  at org.dstadler.jgit.unfinished.PushToRemoteRepository.main(PushToRemoteRepository.java:100)
  </code></pre>
  <p>and my code is</p>
  <pre><code>private static final String REMOTE_URL = &quot;git@192.....:ash/test.git&quot;;
  File localPath = new File(&quot;/home/user/Git&quot;, &quot;&quot;);
  localPath.getParentFile().mkdirs();
  localPath.createNewFile();
  if(!localPath.delete()) {
      throw new IOException(&quot;Could not delete temporary file &quot; + localPath);
  }
  
  Git git = Git.cloneRepository()
          .setURI( REMOTE_URL )
          .setDirectory(localPath)
          .setCredentialsProvider( cp )
          .call();
  System.out.println(&quot;Cloning from &quot; + REMOTE_URL + &quot; to &quot; + localPath);
  
  
  System.out.println(&quot;please edit the file and then press \&quot;Enter\&quot; here to push &quot;);
  System.in.read();
  
  
  File file = new File( git.getRepository().getWorkTree(), &quot;file&quot; + new Object().hashCode() );
  
  git.add().addFilepattern( file.getName() ).call();
  
  git.commit().setAll(true).setMessage(&quot;a message&quot;).call();
  
  git.push() .setCredentialsProvider( cp ) .call();
  
  System.out.println(&quot;Pushed from repository: &quot; + localPath + &quot; to remote repository at &quot; + REMOTE_URL);
  </code></pre>