Can .NET TcpListener class receive data sent via SSH (SFTP)

866 Views Asked by At

I need to receive and parse data sent over SSH via SFTP in my .NET 4.5 application. The SFTP server is running Cygwin OpenSSH on a Windows 2008 server.

I know the .NET TcpListener class can receive and parse data sent via FTP, but I don't know if this is possible with SFTP, and if TcpListener can receive the data, is it necessary or possible to decrypt the data?

Unfortunately, it is a requirement that I receive the data over SSH via SFTP, so requesting to receive the data via FTP or FTPS is not an option.

2

There are 2 best solutions below

4
On BEST ANSWER

OpenSSH does not offer any triggers you could use to process received files.

All you can do is to monitor local file system, where OpenSSH stores the uploaded (received) files.

Or poll the files over SFTP as @user469104 suggested.

Or use a different SFTP server that supports triggers. Though I do not know any free server that supports this.

Ntb, to use TcpListener, you would have to implement SSH/SFTP protocols on your own. What is an immense task.

3
On

You will need to use a third party library, there is no built-in support for SSH or SFTP in .NET.

Also, note that SSH and SFTP are two different protocols. To say that you would receive data over SSH via SFTP sounds weird. Unless you plan on tunneling SFTP traffic over SSH but that would be very unusual.

One option would be to use WinSCP, it can be used to retrieve files over SFTP. It is a native windows command line app but it has a .NET wrapper that allows for automation through .NET.

http://winscp.net/eng/docs/library