可编程,安全的FTP替换

时间:2020-03-05 18:46:19  来源:igfitidea点击:

为了安全起见,我们需要退出传统的FTP(它传输未加密的密码)。我听说SSH被吹捧为显而易见的替代方案。但是,我一直在从ASP.NET程序界面驱动FTP来自动化我的网站开发,现在这是一个高度支持Web的过程。

谁能推荐一种安全的方式来传输文件,该方式具有可以从ASP.NET驱动的程序界面?

解决方案

回答

过去,我们使用了此解决方案的一种变体,该解决方案使用SSH Factory for .NET

回答

sharpssh实现通过scp发送文件。

回答

G'day,

我们可能想看看ProFPD。

高度可定制。基于Apache的模块结构。

从他们的网站:

ProFTPD grew out of the desire to have a secure and configurable FTP server, and out of a significant admiration of the Apache web server.

我们使用改编版进行大规模的Web内容传输。通常每天更新300,000次。

高温超导

干杯,

回答

FTP的传统安全替代方法是SFTP,但是如果我们对两个端点都有足够的控制权,则可以考虑使用rsync:它是高度可配置的,仅通过告诉它使用ssh即可保证安全,并且使两个位置保持同步效率更高。

回答

该问题包含三个子问题:

1)选择安全传输协议

存在旧版FTP的安全版本,称为FTP / SSL(通过SSL加密通道的旧版FTP)。也许我们仍然可以使用旧的部署基础结构,只需检查它是否支持FTPS或者FTP / SSL。

我们可以在http://www.rebex.net/secure-ftp.net/页面上查看有关FTP,FTP / SSL和SFTP差异的详细信息。

2)Windows的SFTP或者FTP / SSL服务器

当我们选择是否使用SFTP或者FTPS我们必须部署正确的服务器。对于FTP / SSL,我们在几台服务器上使用Gene6(http://www.g6ftpserver.com/)不会出现问题。有很多FTP / SSL Windows服务器,因此可以使用任何我们想要的东西。对于Windows的SFTP服务器,情况稍微复杂一些,只有少数可行的实现。 Bitvise WinHTTPD看起来很有前途(http://www.bitvise.com/winsshd)。

3)ASP.NET的Internet文件传输组件

解决方案的最后一部分是从asp.net安全传输文件。市场上有几个组件。我建议Rebex文件传输包同时支持FTP(和FTP / SSL)和SFTP(SSH文件传输)。

以下代码显示了如何通过SFTP将文件上传到服务器。该代码取自我们的Rebex SFTP教程页面。

// create client, connect and log in 
Sftp client = new Sftp();
client.Connect(hostname);
client.Login(username, password);

// upload the 'test.zip' file to the current directory at the server 
client.PutFile(@"c:\data\test.zip", "test.zip");

// upload the 'index.html' file to the specified directory at the server 
client.PutFile(@"c:\data\index.html", "/wwwroot/index.html");

// download the 'test.zip' file from the current directory at the server 
client.GetFile("test.zip", @"c:\data\test.zip");

// download the 'index.html' file from the specified directory at the server 
client.GetFile("/wwwroot/index.html", @"c:\data\index.html");

// upload a text using a MemoryStream 
string message = "Hello from Rebex SFTP for .NET!";
byte[] data = System.Text.Encoding.Default.GetBytes(message);
System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
client.PutFile(ms, "message.txt");

马丁