Can't get SharpSSH to connect via FTP

I'm having trouble getting a secure FTP connection using SharpSSH. So far I have used the DOS command line app MOVEit Freely to connect and it connects fine:

C:\> ftps -user:ABC -password:123 xxx.xxx.xxx.mil

      

However, when I try to do the same with SharpSSH, I get an error indicating either the connection timed out or the server did not respond correctly:

Dim sftp = New Tamir.SharpSsh.Sftp("xxx.xxx.xxx.mil", "ABC", "123")
sftp.Connect()

      

or

Dim host = New Tamir.SharpSsh.SshStream("xxx.xxx.xxx.mil", "ABC", "123")

      

Any idea what I might be doing wrong, or how I can figure out what is failing?

Please note that I need a secure FTP connection, so .NET classes are not an option. I'm willing to try SharpSSH alternatives if they exist, though.

0


a source to share


2 answers


you are using Tamir.SharpSsh which is an SSH library. However, it looks like you are connecting to an FTPS (or FTP / SSL) server. FTPS is a completely different protocol and has nothing to do with SFTP and SSH.

The next page of our website discusses the differences between FTP, FTP / SSL, FTPS and SFTP: rebex.net/secure-ftp.net/ .

Below is a quick overview:

  • FTP is a simple, old, insecure file transfer protocol. Transmitting a text password over the network.

  • FTPS - FTP over TLS / SSL encryption channel. The relationship between FTP and FTPS is similar to that of HTTP and HTTPS.

  • FTP / SSL - same as FTPS

  • SFTP is the SSH File Transfer Protocol. Has nothing to do with FTP (expect name). Runs over an encrypted SSH communication channel.

  • Secure FTP - can be either SFTP or FTPS: - (



You can try the Rebex File Transfer Pack component , which supports SFTP and FTPS (but it costs money, unlike SharpSSH).

The connection to the FTP / SSL server will look like this:

' Create an instance of the Ftp class. 
Dim ftp As New Ftp()

' Connect securely using explicit SSL. 
' Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 21, Nothing, FtpSecurity.Explicit)

' Connection is protected now, we can log in safely. 
ftp.Login(username, password)

      

+2


a source


Another great alternative (also not free) is edtFTPnet / PRO , a stable, mature library that offers full FTPS (and SFTP) support in .NET.

Here's a sample code to connect:



   SecureFTPConnection ftpConnection = new SecureFTPConnection();

   // setting server address and credentials
   ftpConnection.ServerAddress = "xxx.xxx.xxx.mil";
   ftpConnection.UserName = "ABC";
   ftpConnection.Password = "123";

   // select explicit FTPS
   ftpConnection.Protocol = FileTransferProtocol.FTPSExplicit;

   // switch off server validation (only do this when testing)
   ftpConnection.ServerValidation = SecureFTPServerValidationType.None;

   // connect to server
   ftpConnection.Connect();

      

+2


a source







All Articles