Link to home
Start Free TrialLog in
Avatar of sidwelle
sidwelleFlag for United States of America

asked on

.net Sftp request.EnableSsl

Looking for a code snip that will retrieve a file and dir listing from a SFTP server.

Found a couple of examples on-line look promising but keep getting an error:

"System.Net.WebException: The remote server returned an error: 234 SSL enabled... start negotiation . ---> System.IO.IOException: The handshake failed due to an unexpected packet format.  ..."

    Dim request As System.Net.FtpWebRequest = DirectCast(WebRequest.Create(New Uri("ftp://sftp.domain.com/myFile.txt")), System.Net.FtpWebRequest)
    request.Method = WebRequestMethods.Ftp.DownloadFile
    request.EnableSsl = True
    request.Credentials = New Net.NetworkCredential("username", "password")
    request.UsePassive = True
    Dim response As System.Net.FtpWebResponse = DirectCast(request.GetResponse(), System.Net.FtpWebResponse)

Open in new window


Any help is appreciated.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

SFTP uses SSH, not SSL/TLS.  They are not the same or even compatible encryption methods.  You will have to find an SSH/SFTP library to make that connection.
Avatar of sidwelle

ASKER

I see a lot of examples using the "SharpSSH" library, are there any others ?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dazve, thanks for the help.