.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.
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Dave BaldwinFixer of ProblemsCommented:
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.
sidwelleAuthor Commented:
I see a lot of examples using the "SharpSSH" library, are there any others ?
sidwelleAuthor Commented:
Dazve, thanks for the help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.