出于安全目的,我们需要摆脱传统的 FTP(它传输的密码未加密)。我听说 SSH 被吹捧为明显的替代方案。然而,我一直在从一个 ASP.NET 程序接口驱动 FTP 来自动化我的网站开发,这现在是一个高度支持 Web 的过程。
谁能推荐一种安全的方式来传输具有我可以从 ASP.NET 驱动的程序接口的文件?
sharpssh实现通过 scp 发送文件。
这个问题有三个子问题:
1) 选择安全传输协议
旧 FTP 的安全版本存在 - 它称为 FTP/SSL(普通旧 FTP over SSL 加密通道)。也许您仍然可以使用旧的部署基础架构 - 只需检查它是否支持 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");
马丁
我们过去曾使用过此解决方案的变体,它使用 .NET 的 SSH 工厂
天,
您可能想看看ProFPD。
高度可定制。基于Apache的模块结构。
从他们的网站:
ProFTPD 的产生源于对拥有安全且可配置的 FTP 服务器的渴望,以及对 Apache Web 服务器的极大钦佩。
我们使用我们的改编版本来大规模传输网络内容。通常每天更新 300,000 次。
高温高压
干杯,
抢