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

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

问题描述

我有一个要求,例如需要创建一个 C# 应用程序,该应用程序将根据 app.config 文件中输入的设置将 excel 文件上传到FTP/SFTP"服务器(使用ftpftpssftp").

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 "ftpftpssftp").

我对这些协议很陌生,有很多疑问.

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

  1. FTP 和 SFTP 服务器有什么区别?
  2. 是否可以使用 SFTP 连接方式访问 FTP 服务器,反之亦然(指导使用 Rebex 库连接 SFTP)?
  3. 如何将以下 FTP 上传方式更改为 FTPS

代码如下:

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(); 

是否像将 url 从 FTP 更改为 FTPS?

Is it like changing url from FTP to FTPS?

string 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 可以在单个应用程序中处理所有这些协议.

    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.

    关于将 FTPS 与 FtpWebRequests 一起使用,请参阅 msdn.无法将 SFTP 与 FtpWebRequests 一起使用,但有其他库.

    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天全站免登陆