My Windows client application (written in C#) works with the remote MySQL database deployed on *NIX server.
I'm going to add the ability to store files on the server. I was never fond of storing files in DB, so the files will be stored in the file system. The application will need to upload, download, and delete files from server.
Any approach I can think of requires additional service to be deployed on server.
So far my favorite is SFTP*, but there are other solutions which are IMO inferior:
Web Service - are there any? haven't done any research in this direction.
FTP server - brings at least all the problems connected with protocol itself
WebDAV - interesting option, considering there is Apache module and .NET libraries
Some ad-hoc script (clearly the worst solution)
*I intend to use SharpSSH library, and public key authentication to access special account on the server which will be restricted to SSH operations only
Edit: corrected some terms confusion, thanks to #vartec
SCP has rather limited functionality. SFTP and FISH give you a lot more then plain SCP. (note, that SFTP should not be confused with FTPS)
Example of SFTP C# implementation.
Advantage over other options — no extra configuration at server side required.
I would use vsftpd on the *NIX server side: it's small and easy to configure, and I haven't had any problems with it since I initially set it up about 6 months ago so it's also reliable. I just use regular FTP, but you can do SSL with vsftpd if you're concerned about security.
On the client side there is this free, open source, FTP Client Library for C# made by Dan at C-SharpCorner.com. It works, and it's easy to extend its functionality to do more things. For example, I added a function for changing file permissions on the remote server.
putty and winscp are all you need.
Related
I need to create a C# client with .NET Framework 4.6.2 to connect a server.
My client offers me the possibility to connect to a SFTP server or to a FTPS server, but I don't know which one is the best to connect with.
On this page, I have found this:
No built-in SSH/SFTP support in VCL and .NET frameworks
I need to connect to a server to upload and download files. I also need to monitor a directory on the server to know when a file is on that remote directory.
Searching on Internet I'm not sure if the .NET libraries (SSHNet) that implements SFTP protocol are good enough to a production environment.
I think SFTP is the best option to use but FTPS could be easier to implement a C# client for it.
Or maybe I can use libssh2 to implement a C program that do the job to monitor a remote directory, download any new file on it and upload the files that I need to upload.
Any advice?
If both protocols are fine for your actual needs (as suggested in your question and comments), if it's only a matter of "what's the easiest to use in .Net", I would simply go for FTPS.
It's very fast to implement, since you'll find all what you need in the framework ("FtpWebRequest" class, or more recently "WebClient", etc), even on old versions of the framework.
You can find plenty resource about this on the web or on SO
You have mentioned that you need to "monitor" a folder on remote server. Of course there's no problem with FTPS to retrieve the list of all files of a folder, but it will be in "pull" mode, as frequently as you wish. There's no way for the server itself to push you a notification every time a new file has been dropped. So if you need some real-time notifications, it's not optimal.
Sorry I think I am finally asking the right question. First I asked Create a shell namespace extension
Anyways I am synchronizing and sharing files between two peers just like drobox but with larger data. I was wondering how could I create a web share or ftp share server so that I can connect to it from windows.
For example when you click on:
Then
if I select ftp://ftp.microsoft.com
then this is what I get:
From researching on the internet I saw that IIS supports this. I was wondering if there are some libraries that will enable me to create this server on c#.
You could use Apache server to do turn your computer into a hosting server. Apache comes with many software packages such as xampp, wampp which help reduce installing time.
I've data on a mac server, on which I've several files.
I've to do a c# program which connect to the server and retrieve files which are different.
The server and the workstation will not be on the same network, so I need to have a secure access(the encryption is a plus, but it's mostly about other people cannot go read files on the server).
I taught of several things:
Rsync over SSH(but I didn't found any good library on the .net server, which manage ssh and is recent enough)
Samba(not secure enough?)/SFtp access(but I need to do myself the hash mecanism, check on dates, ...)
What is my best option? Do you have an other (better) idea?
I would definitely use Samba/CIFS. Why is this not secure enough? It is used by Windows operating systems (the MS implementation of it) all over the wolds, in enterprise systems.
Why do you think it is not secure enough?
I'd like to build an home FTP SERVER - that will store all my files and the rest of my computers will upload and download files to and from it.
I don't like to start from scratch, do you know of a c# ftp server implementation?
Can you give me some guidelines of where to start what I should know etc?
Based on a few of your comments why do you not just enable the FTP server through IIS on one of your computers in your network, or just enable file sharing? These things are already partof/included in Windows at your disposal.
You say you don't want to start from scratch, so use something that's already been through the pain: http://filezilla-project.org/
The FTP RFCs for the protocol specification and the System.Net.Sockets namespace.
And read as much as you can on security (mailing list, bulletins, books, ...) because you can very easily leave holes for anyone to get to your files.
(I don't know of any FTP libraries beyond what .NET includes (I've not needed any FTP), but there are also third party networking component libraries that may include richer functionality. You'll likely still need to understand what's going on for debugging.)
You first need to understand the protocol: RFC959
Here a basic server in C#: http://www.c-sharpcorner.com/UploadFile/ivar/FTPServer12072005041005AM/FTPServer.aspx
Read on security...
I'm surprised by the lack of products out there for running your own FTP server in managed code. I'm looking for either a product or thorough source code for building an FTP server in C# that supports SSL. I need complete control over the directory/file handling, not just serving files from a local directory.
Clever Internet .NET Suite looks to be exactly what I'm looking for. However, when I tried it out I got errors connecting to the FtpServerSSL sample from FileZilla when SSL was enabled. It worked perfectly without SSL, so I wrote to their support, but I haven't heard a response from them yet.
Never done it myself, but you could try one of these:
http://www.c-sharpcorner.com/UploadFile/psingh/FTPServerinCSharp11162005015958AM/FTPServerinCSharp.aspx
http://www.codeguru.com/csharp/csharp/cs_network/sockets/article.php/c7409/
You secure the port using httpcfg or netsh in windows, not in the app.
We plan to release FTP / FTPS server components within a month as part of our SecureBlackbox product. The components are currently being internally tested. As SecureBlackbox is a security suite, SSL part will work there :).