无法使用 Fluent FTP 登录(错误 530 – 未登录),但 GUI FTP 客户端可以正常工作

Cannot login in with Fluent FTP (Error 530 – Not Logged In), but GUI FTP client works

此代码块旨在打开本地计算机与 FTP 服务器之间的连接。服务器由 DreamHost 托管,我不知道问题是否出在我对目标 DreamHost 服务器的配置中。代码抛出 WebException:

530 (Not Logged In)

// Censored, but all the information given are correct
using (FtpClient ftp = new FtpClient("anaconda.dreamhost.com", "******", "******")) 
{
     ftp.Connect(); // This line
     ..
     ..
}

如何成功初始化与服务器的连接?


我也试过使用 FileZilla 登录。它似乎工作正常。日志文件如下:

2021-04-25 18:53:41 2404 1 Status: Connecting to anaconda.dreamhost.com...
2021-04-25 18:53:42 2404 1 Response: fzSftp started, protocol_version=10
2021-04-25 18:53:42 2404 1 Command: open "***********@anaconda.dreamhost.com" 2
2021-04-25 18:53:55 2404 1 Status: Using username "********".
2021-04-25 18:53:57 2404 1 Command: Pass: ********
2021-04-25 18:54:00 2404 1 Status: Connected to anaconda.dreamhost.com
2021-04-25 18:54:02 2404 1 Status: Retrieving directory listing...
2021-04-25 18:54:02 2404 1 Command: pwd
2021-04-25 18:54:02 2404 1 Response: Current directory is: "/home/*******"
2021-04-25 18:54:02 2404 1 Command: ls
2021-04-25 18:54:03 2404 1 Status: Listing directory /home/********
2021-04-25 18:54:04 2404 1 Status: Directory listing of "/home/******" successful

我很确定问题出在我上面代码的配置中。

您在 FileZilla 中使用的是 SFTP,而不是 FTP。

所以你必须在代码中使用 SFTP 库,而不是 FTP 库。

How to communicate with SFTP server