title: Jenkins master fails to connect to the slave over SSH
body: <p>Jenkins master is running on Amazon instance and slave machine set up on dedicated Soyoustart machine. Worked fine until it was needed to redo the slave setup: reinstalled the OS, installed Java, added masters key to slave authorized_keys and removed/added again the slave in masters known_hosts. Set up new credentials for the slave and configured the node in Jenkins master but it is unable to connect to the slave.</p>
  
  <p>The setup is the the same that is and has been working with other slaves without hiccups. The only thing different is that this time the new slave is the same machine with the IP as the old one was.</p>
  
  <p>It is possible to ssh into the slave from master from CLI(replaced filename and slave IP with placeholder for this post):
  <code>$ ssh -i &lt;key-file&gt; jenkins@&lt;slave-ip&gt;</code></p>
  
  <p><strong>Credentials have been set up :</strong>
  <img src="https://i.stack.imgur.com/8ZXsX.png" alt="enter image description here"></p>
  
  <p><strong>Node is configured:</strong>
  <img src="https://i.stack.imgur.com/GwjdG.png" alt="enter image description here"></p>
  
  <p><strong>Output when connecting to the slave:</strong></p>
  
  <pre><code>[05/17/15 07:30:31] [SSH] Opening SSH connection to &lt;slave-ip&gt;.
  Key exchange was not finished, connection is closed.
  ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
  java.lang.IllegalStateException: Connection is not established!
  at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:1030)
  at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.getRemainingAuthMethods(TrileadSSHPublicKeyAuthenticator.java:88)
  at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPublicKeyAuthenticator.canAuthenticate(TrileadSSHPublicKeyAuthenticator.java:80)
  at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:207)
  at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:169)
  at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1173)
  at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:701)
  at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:745)
  [05/17/15 07:30:31] Launch failed - cleaning up connection
  [05/17/15 07:30:31] [SSH] Connection closed.
  </code></pre>
  
  <p><strong>Version numbers:</strong></p>
  
  <ul>
  <li>Jenkins 1.613</li>
  <li>SSH Credentials Plugin 1.11</li>
  <li>SSH Slaves plugin 1.9</li>
  </ul>
  
  <p><strong>For those who prefer to dig into code:</strong></p>
  
  <ul>
  <li><p><a href="https://github.com/jenkinsci/ssh-credentials-plugin" rel="noreferrer" title="Code in Github">SSH Credentials Plugin</a></p></li>
  <li><p><a href="https://github.com/jenkinsci/ssh-slaves-plugin" rel="noreferrer" title="Code in Github">SSH Slave Plugin</a></p></li>
  <li><p><a href="https://github.com/jenkinsci/trilead-ssh2" rel="noreferrer" title="Code in Github">Trilead SSH</a></p></li>
  </ul>
  
  <p>Am I missing something obvious here? What could be causing this? Any known workaround? Or does it look like a bug that needs to be reported?</p>
  
  <p>Please let me know if more information is needed.</p>