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

问题描述

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

530(未登录

// 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 状态:连接到 anaconda.dreamhost.com...
2021-04-25 18:53:42 2404 1 响应:fzSftp 启动,protocol_version=10
2021-04-25 18:53:42 2404 1 命令:打开“***********@anaconda.dreamhost.com”2
2021-04-25 18:53:55 2404 1 状态:使​​用用户名“********”。
2021-04-25 18:53:57 2404 1 命令:通过:********
2021-04-25 18:54:00 2404 1 状态:连接到 anaconda.dreamhost.com
2021-04-25 18:54:02 2404 1 状态:正在检索目录列表...
2021-04-25 18:54:02 2404 1 命令:pwd
2021-04-25 18:54:02 2404 1 响应:当前目录为:“/home/*******”
2021-04-25 18:54:02 2404 1 命令:ls
2021-04-25 18:54:03 2404 1 状态:列出目录 /home/********
2021-04-25 18:54:04 2404 1 状态:“/home/******”目录列表成功

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

解决方法

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

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

How to communicate with SFTP server