FTP / FTPS / SFTP之间的区别 - 配置连接到其中的任何 [英] Difference between FTP/FTPS/SFTP - Configurable connection to any of them

查看:711
本文介绍了FTP / FTPS / SFTP之间的区别 - 配置连接到其中的任何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样需要创建一个C#应用程序,它会上传一个Excel文件要求的基础上的的app.config 文件中输入设置FTP / SFTP服务器(用ftp\ftps\sftp)。



我新鲜这些协议,有这么多的疑问。




  1. 什么是FTP和SFTP服务器之间的区别?

  2. 是否有可能通过SFTP连接方法,反之亦然访问FTP服务器(引导使用Rebex的库连接到SFTP)?

  3. 如何更改以下FTP上传方法FTPS



代码如下:

 字符串PureFileName =新的FileInfo(文件名).Name点; 
串的uploadURL =的String.Format(FTP:// {0} / {1},ftpurl,PureFileName);
的FtpWebRequest REQ =(的FtpWebRequest)FtpWebRequest.Create(的uploadURL);
req.Proxy = NULL;
req.Method = WebRequestMethods.Ftp.UploadFile;
req.Credentials =新的NetworkCredential(user和pass);
req.UseBinary = TRUE;
req.UsePassive = TRUE;
字节[]数据= File.ReadAllBytes(文件名);
req.ContentLength = data.Length;
流流= req.GetRequestStream();
stream.Write(数据,0,data.Length);
stream.Close();
FtpWebResponse解析度=(FtpWebResponse)req.GetResponse();



是不是像改变网址从FTP到FTPS?

 字符串的uploadURL =的String.Format(FTPS:// {0} / {1},ftpurl,PureFileName); 


解决方案

  • FTP:老文件传输协议(RFC959)。问题与防火墙,因为它使用动态端口这些端口的信息会在应用层交换

  • FTPS:老FTP的TLS协议,但是支持增加。更成问题的有,因为这些防火墙可以不再考虑应用层面,找出它们使用的端口

  • SFTP:完全不同的东西,因为它使用SSH协议来传输文件。没有问题的防火墙。



如果你的代码能够处理FTPS它通常是能够处理FTP太多,但有很多代码,只能处理FTP和FTPS没有。由于SFTP是一个完全不同的协议代码处理FTP / FTPS通常不能够做到SFTP。和SFTP处理代码不会做FTP / FTPS。但也有例外,如FileZilla中可以处理一个单一的应用程序的所有这些协议。



至于使用FTPS与FtpWebRequests看到的 MSDN 。使用SFTP与FtpWebRequests是不可能的,但也有其他库


I have a requirement like need to create a C# app which will upload an excel file to "FTP/SFTP" server based on settings entered on the app.config file (using "ftp\ftps\sftp").

I am fresh to these protocols, having so many doubts.

  1. What is the difference between FTP and SFTP server?
  2. Is it possible to access FTP server using SFTP connection methods and vice versa (guided to use Rebex library to connect to SFTP)?
  3. How can change following FTP upload method to FTPS

Code is below:

string PureFileName = new FileInfo(fileName).Name;
string uploadUrl = String.Format("ftp://{0}/{1}", ftpurl, PureFileName);
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(uploadUrl);
req.Proxy = null;
req.Method = WebRequestMethods.Ftp.UploadFile;
req.Credentials = new NetworkCredential(user, pass);
req.UseBinary = true;
req.UsePassive = true;
byte[] data = File.ReadAllBytes(fileName);
req.ContentLength = data.Length;
Stream stream = req.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
FtpWebResponse res = (FtpWebResponse)req.GetResponse(); 

Is it like changing url from FTP to FTPS?

string uploadUrl = String.Format("ftps://{0}/{1}", ftpurl, PureFileName);

解决方案

  • FTP: the old file transfer protocol (RFC959). Problematic with firewalls since it is using dynamic ports and the information about these ports gets exchanged at the application level.
  • FTPS: the old FTP protocol but support for TLS added. Even more problematic with firewalls since these can no longer look into the application level to find out which ports are used.
  • SFTP: something completely different, because it uses the SSH protocol to transfer files. No problems with firewalls.

If your code is able to handle FTPS it is usually able to handle FTP too, but there is lots of code which can only handle FTP and not FTPS. Since SFTP is a completely different protocol code handling FTP/FTPS will usually not be able to do SFTP. And SFTP handling code will not do FTP/FTPS. There are exceptions, i.e. FileZilla can handle all these protocols in a single application.

As for using FTPS with FtpWebRequests see msdn. Using SFTP with FtpWebRequests is not possible but there are other libraries.

这篇关于FTP / FTPS / SFTP之间的区别 - 配置连接到其中的任何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆