Search code examples
.netftpsftpsharpssh

Can't get SharpSSH to connect via FTP


I'm having trouble making a secure FTP connection using SharpSSH. Up to now I've been using the DOS command line app MOVEit Freely to make the connection, and it connects fine:

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

However, when I try to do the same thing with SharpSSH, I get an error that says either the connection timed out or the server didn't 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 could figure out what's failing?

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


Solution

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

    Following page on our website discusses the differences between FTP, FTP/SSL, FTPS and SFTP protocols: rebex.net/secure-ftp.net/.

    Brief summary follows:

    • FTP plain, old, insecure file transfer protocol. Transfers clear text password over the network.

    • FTPS - FTP over TLS/SSL encrypted channel. FTP and FTPS relation is similar to HTTP and HTTPS.

    • FTP/SSL - same as FTPS

    • SFTP - SSH File Transfer Protocol. Has nothing common with FTP (expect the name). Runs over SSH encrypted communication channel.

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

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

    Connection to FTP/SSL server would 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)