title: SSH / SFTP connection issue using Tamir.SharpSsh
body: <p>This is my code to connect and send a file to a remote SFTP server.</p>
  
  <pre><code>public static void SendDocument(string fileName, string host, string remoteFile, string user, string password)
          {            
              Scp scp = new Scp();
  
              scp.OnConnecting += new FileTansferEvent(scp_OnConnecting);
              scp.OnStart += new FileTansferEvent(scp_OnProgress);
              scp.OnEnd += new FileTansferEvent(scp_OnEnd);
              scp.OnProgress += new FileTansferEvent(scp_OnProgress);
  
              try
              {
                  scp.To(fileName, host, remoteFile, user, password);
              }
              catch (Exception e)
              {
                  throw e;
              }
          }
  </code></pre>
  
  <p>I can successfully connect, send and receive files using CoreFTP.  Thus, the issue is not with the server.  When I run the above code, the process seems to stop at the scp.To method.  It just hangs indefinitely.  </p>
  
  <p>Anyone know what might my problem be?  Maybe it has something to do with adding the key to the a SSH Cache?  If so, how would I go about this?</p>
  
  <p><strong>EDIT:</strong> I inspected the packets using wireshark and discovered that my computer is not executing the Diffie-Hellman Key Exchange Init.  This must be the issue.  </p>
  
  <p><strong>EDIT:</strong> I ended up using the following code.  Note, the StrictHostKeyChecking was turned off to make things easier.</p>
  
  <pre><code>            JSch jsch = new JSch();
              jsch.setKnownHosts(host);
  
              Session session = jsch.getSession(user, host, 22);
              session.setPassword(password);
  
              System.Collections.Hashtable hashConfig = new System.Collections.Hashtable();
              hashConfig.Add("StrictHostKeyChecking", "no");
              session.setConfig(hashConfig);
  
              try
              {
                  session.connect();
  
                  Channel channel = session.openChannel("sftp");
                  channel.connect();
                  ChannelSftp c = (ChannelSftp)channel;
  
                  c.put(fileName, remoteFile);
  
                  c.exit();            
              }
              catch (Exception e)
              {
                  throw e;
              }
  </code></pre>
  
  <p>Thanks.</p>