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.
Related
I have been making a simple ftp of my JCL after sending site filetype=jes with my C# code.
However now I am required to use SFTP to send and receive files.
I found renci.SshNet but it does not have a method to send command.
Can someone please tell me how I can SFTP a JCL to mainframe using C#?
What is the best method to go about this?
SFTP (not to be confused with FTPS) is not supported by .NET out of the box. You have to rely on a 3rd party library. See related question here: SFTP Libraries for .NET
The answer for your stated problem is that you need FTPS and not SFTP to support JES extensions for job submission and retrieval (as well as other z/OS specific capabilities).
Here is an article that goes over the details of FTPS in c#. Its the same command sequence using the SITE command as you used under FTP.
For a comparison of SFTP and FTPS here is some information.
Found this link about FTPS setup on z/OS from Share. This should get you started. It seems more practical and applied than going to knowledge center and shows the various options and capabilities. The original author, Alfred B Christensen, is an IBMer. The material is from 2011 but is still mostly applicable today.
Here is a comparison of the technologies:
Here is some more background.
The issue is that ...sftp understands a set of commands subcommands similar to those of ftp. according to the linked IBM manual for SFTP. The sftp server implementation provided by IBM does not have the full set of extensions provided by the FTP Server
There are other servers out there with associated clients that can provide the capability. I'm not endorsing this product but it seems to be popular from google searches I've done Tectia The default implementation of sftp server from IBM does not support the same extensions that ftp does.
If you're looking for a seamless transition and need transport security ftps is a better option but likely requires configuration on the z/OS system if its not already enabled.
The issue is not simply the client, it is the capability of the sftp implementation on z/OS as well.
The native SFTP from IBM does not support all the features of FTP. You will need to use Co:Z toolkit SFTP from Dovetailed. It's free to use with paid support available.
I have the following requirement: in an existing webapplication we have a user management. In this you should be able to say for user xyz he should have access to an SFTP-Server lets say with a checkbox option: Allow access to SFTP.
If the option gets selected it should do the following thing:
-> Create a login on the SFTP-Server User: xyz Passwort xzy
-> Create a folder for user /root/xyz with read and write permission (isolated from others)
Anyone has done something similar or an idea how to archive this? What I found so far is .NET FTP authentication which works with IIS (but seems IIS supports only FTP/S not SFTP).
The SFTP is not set up by now, so could be any (prefered on another server)
Would appreciate any help :)
Seems like what you need is an SFTP (thus SSH) server that allows you to create users via some sort of command-line or - better - via remote calls. Depending on the server there may be several ways to do that.
if the server allows you to have SSH shell access (which I would strongly discourage!!) then you could open a shell and on it and use your OS/server command line tools to create/manage user profiles there
if the server has its own CLI (command-line interface) and such CLI allows for remote configuration, then you could invoke it from your web application (make sure permissions allow you to do so) and do it that way
the best way to do it, though, would be to have a server that can be configured via REST API, so you could simply call such REST API from within the context of your web application, and manage your SFTP server's users that way
Since you have not deployed your SFTP server yet, and if you have the liberty to pick any SFTP server you see fit, then you may want to try Syncplify.me Server!, which gives you all 3 options listed above.
(disclaimer: I work at Syncplify)
Often times a program requires a file that happens to be on a network location. Take for instance Outlook. If I where to place an outlooks database (.pst file) in a network location then windows will make that "transparent" to the user and outlook will still be able to work. Another example could be quickbooks and many more. (as long as you have permissions to write and read)
For this example let's use Microsoft Word. If I would want to open a file in some other computer in the network I would be able to navigate to it as:
and open the file that I want because we are on the same network.
Now my question is how will I be able to simulate that? I want to have a virtual directory on the internet where I can place lets say my .pst file and then select it from windows explorer as:
(this example obviously does not work)
Will it be possible to do that? I believe windows uses a tcp connection with the host computer and then the host responds with he files that it shares. I will like to implement a program that does that so that I could avoid having to create a vpn. Also it will be nice if I could have my pst (outlook database file) on the internet so that all my computers open the same outlook database.
Note my purpose of this question is to open an outlook database file on a network location. I will like to be able to select a file on the internet from windows open file dialog. Also in todays world everything pretty much exists. I will like to create it lol
Windows provides a network redirector for CIFS (Common Internet File System, formerly SMB Server Message Block) resources. Writing a CIFS server is the easiest approach.
But you can also use one of the other existing redirectors, such as NFS, WebDAV, or Netware. And it's also possible to write new redirectors (though that requires kernel mode code, there are some development kits that provide the kernel code for you, similar to a Linux FUSE filesystem).
If you want to avoid writing code, WebDAV over HTTPS will provide you secure access (no need for a VPN layer) and software already exists.
It depends on how the server on the internet is set up to make its files available. Most often tcpip is not the protocol used for this - it is FTP, SFTP, HTTP or something similar. I believe Windows Explorer uses RPC calls over a local network to accomplish this. I don't think you will be able to use the Open File Dialog, you will have to write something similar that works over the protocol you need to use.
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...
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.