无法让 SharpSSH 通过 FTP 连接

发布于 2024-07-22 05:20:35 字数 554 浏览 7 评论 0原文

我在使用 SharpSSH 建立安全 FTP 连接时遇到问题。 到目前为止,我一直在使用 DOS 命令行应用程序 MOVEit Freely 进行连接,并且连接正常:

C:\> ftps -user:ABC -password:123 xxx.xxx.xxx.mil

但是,当我尝试使用 SharpSSH 执行相同操作时,出现错误,提示连接超时或服务器没有正确响应:

Dim sftp = New Tamir.SharpSsh.Sftp("xxx.xxx.xxx.mil", "ABC", "123")
sftp.Connect()

或者

Dim host = New Tamir.SharpSsh.SshStream("xxx.xxx.xxx.mil", "ABC", "123")

知道我可能做错了什么,或者我如何找出失败的原因?

请注意,我需要安全的 FTP 连接,因此 .NET 类不是一个选项。 如果 SharpSSH 存在的话,我愿意尝试它们。

I'm having trouble making a secure FTP connection using SharpSSH. Up to now I've been using the DOS command line app MOVEit Freely to make the connection, and it connects fine:

C:\> ftps -user:ABC -password:123 xxx.xxx.xxx.mil

However, when I try to do the same thing with SharpSSH, I get an error that says either the connection timed out or the server didn't respond correctly:

Dim sftp = New Tamir.SharpSsh.Sftp("xxx.xxx.xxx.mil", "ABC", "123")
sftp.Connect()

or

Dim host = New Tamir.SharpSsh.SshStream("xxx.xxx.xxx.mil", "ABC", "123")

Any idea what I might be doing wrong, or how I could figure out what's failing?

Note that I need a secure FTP connection, so the .NET classes are not an option. I'm willing to try alternatives to SharpSSH if they exist though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫儰鉨ミ守葔 2024-07-29 05:20:35

您正在使用 Tamir.SharpSsh,它是一个 SSH 库。 但是,您似乎正在连接到 FTPS(或 FTP/SSL)服务器。 FTPS 是完全不同的协议,与 SFTP 或 SSH 没有任何共同点。

我们网站上的以下页面讨论了 FTP、FTP/SSL、FTPS 和 SFTP 协议之间的差异:rebex .net/secure-ftp.net/

简要总结如下:

  • FTP 是简单、陈旧、不安全的文件传输协议。 通过网络传输明文密码。

  • FTPS - 通过 TLS/SSL 加密的 FTP
    渠道。 FTP和FTPS的关系是
    类似于 HTTP 和 HTTPS。

  • FTP/SSL - 与 FTPS 相同

  • SFTP - SSH 文件传输协议。 与 FTP 没有任何共同点(期待名称)。 通过 SSH 加密通信通道运行。

  • 安全 FTP - 可以是 SFTP 或 FTPS :-(

您可以尝试 Rebex File Transfer Pack 组件,它支持 SFTP 和 FTPS 协议(但与 SharpSSH 不同,它要花费一些钱)。

连接到 FTP/SSL 服务器看起来像这:

' Create an instance of the Ftp class. 
Dim ftp As New Ftp()

' Connect securely using explicit SSL. 
' Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 21, Nothing, FtpSecurity.Explicit)

' Connection is protected now, we can log in safely. 
ftp.Login(username, password)

you are using Tamir.SharpSsh, which is a SSH library. However, it looks like you are connecting to FTPS (or FTP/SSL) server. The FTPS is completely different protocol and has nothing common with SFTP nor SSH.

Following page on our website discusses the differences between FTP, FTP/SSL, FTPS and SFTP protocols: rebex.net/secure-ftp.net/.

Brief summary follows:

  • FTP plain, old, insecure file transfer protocol. Transfers clear text password over the network.

  • FTPS - FTP over TLS/SSL encrypted
    channel. FTP and FTPS relation is
    similar to HTTP and HTTPS.

  • FTP/SSL - same as FTPS

  • SFTP - SSH File Transfer Protocol. Has nothing common with FTP (expect the name). Runs over SSH encrypted communication channel.

  • Secure FTP - could be either SFTP or FTPS :-(

You may try Rebex File Transfer Pack component, which supports both SFTP and FTPS protocols (but it costs some money unlike the SharpSSH).

Connection to FTP/SSL server would look like this:

' Create an instance of the Ftp class. 
Dim ftp As New Ftp()

' Connect securely using explicit SSL. 
' Use the third argument to specify additional SSL parameters. 
ftp.Connect(hostname, 21, Nothing, FtpSecurity.Explicit)

' Connection is protected now, we can log in safely. 
ftp.Login(username, password)
煞人兵器 2024-07-29 05:20:35

另一个不错的选择(也不是免费的)是 edtFTPnet/PRO,一个稳定的、成熟的库,为 .NET 中的 FTPS(和 SFTP)提供全面支持。

以下是一些用于连接的示例代码:

   SecureFTPConnection ftpConnection = new SecureFTPConnection();

   // setting server address and credentials
   ftpConnection.ServerAddress = "xxx.xxx.xxx.mil";
   ftpConnection.UserName = "ABC";
   ftpConnection.Password = "123";

   // select explicit FTPS
   ftpConnection.Protocol = FileTransferProtocol.FTPSExplicit;

   // switch off server validation (only do this when testing)
   ftpConnection.ServerValidation = SecureFTPServerValidationType.None;

   // connect to server
   ftpConnection.Connect();

Another great alternative (also not free) is edtFTPnet/PRO, a stable, mature library which offers full support for FTPS (and SFTP) in .NET.

Here's some sample code for connecting:

   SecureFTPConnection ftpConnection = new SecureFTPConnection();

   // setting server address and credentials
   ftpConnection.ServerAddress = "xxx.xxx.xxx.mil";
   ftpConnection.UserName = "ABC";
   ftpConnection.Password = "123";

   // select explicit FTPS
   ftpConnection.Protocol = FileTransferProtocol.FTPSExplicit;

   // switch off server validation (only do this when testing)
   ftpConnection.ServerValidation = SecureFTPServerValidationType.None;

   // connect to server
   ftpConnection.Connect();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文