ComponentPro UltimateSftp

      Reuse SSH connection in SFTP, SCP, or SSH sessions

      Language Filter: AllSend comments on this topic to ComponentPro

      The SSH client classes that implement the ISecureShellClient interface can share the connection with other protocol sessions. To reuse connection of another SSH session, use the ReuseConnection method. All the SFTP, SCP, or SSH sessions use the same underlying SSH connection.

      // Create a new instance of the Sftp class. 
      using (Sftp sftp1 = new Sftp())
          // Connect to the server. 
          // Authenticate the user 
          sftp1.Authenticate(userName, password);
          Sftp sftp2 = new Sftp();
          // Reuse the connection from the sftp1 instance. 
          // Download files 
          sftp1.DownloadFile("/data/file1.dat", @"c:\data\file1.dat");
          sftp2.DownloadFile("/data/file2.dat", @"c:\data\file2.dat");