title: Why does programmatic SSH to server using ganymed-ssh-2 results in Key Exchange error?
body: <p>I'm using the ganymed-ssh-2 Java library to create a connection from one AWS EC2 to another (in the same VPC) and the 'connect()' command gives the following error:</p>
  
  <pre><code>java.io.IOException: Key exchange was not finished, connection is closed.
      at ch.ethz.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:75)
      at ch.ethz.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:169)
      at ch.ethz.ssh2.Connection.connect(Connection.java:759)
      at ch.ethz.ssh2.Connection.connect(Connection.java:628)
      at bravura.autoperf.executor.SSHExecutor.connectTo(SSHExecutor.java:156)
      at bravura.autoperf.executor.SSHExecutor.runRemoteSSHCommand(SSHExecutor.java:57)
      at bravura.autoperf.executor.SSHExecutor.runRemoteSSHCommand(SSHExecutor.java:141)
      at bravura.autoperf.util.Utilities.runCommandRepeatedly(Utilities.java:614)
      at bravura.autoperf.test.Server.getServerDetails(Server.java:233)
      at bravura.autoperf.test.Server.&lt;init&gt;(Server.java:127)
      at bravura.autoperf.test.Server.&lt;init&gt;(Server.java:65)
      at bravura.autoperf.util.Utilities.getClientServer(Utilities.java:499)
      at bravura.autoperf.manager.RunSetupManager.&lt;init&gt;(RunSetupManager.java:69)
      at bravura.autoperf.manager.ExecutionManager.runTests(ExecutionManager.java:171)
      at bravura.autoperf.manager.ExecutionManager.main(ExecutionManager.java:64)
  Caused by: java.io.IOException: Cannot negotiate, proposals do not match.
      at ch.ethz.ssh2.transport.ClientKexManager.handleMessage(ClientKexManager.java:123)
      at ch.ethz.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:572)
      at ch.ethz.ssh2.transport.TransportManager$1.run(TransportManager.java:261)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>Calling code:</p>
  
  <pre><code>    Connection connection = new Connection(host);
      connection.connect();
  </code></pre>
  
  <p>This is before the 'authenticateWithPublicKey()' method has had a chance to be called.</p>
  
  <p>The NACL and relevant security group have been opened up for port 22 traffic for the VPC CIDR range (which both instances are in).
  The Route Table routes all VPC CIDR traffic locally.</p>
  
  <p>I can manually ssh with no issues.</p>
  
  <p>(OS is Amazon Linux 2 fwiw)</p>
  
  <p>Thanks for any help.</p>