Java Apache Commons net FTPClient,登录不正确
我正在使用FTPClient使用username/pwd连接我们的一台服务器。但我总是收到530个不正确的登录信息Java Apache Commons net FTPClient,登录不正确,java,ftp-client,Java,Ftp Client,我正在使用FTPClient使用username/pwd连接我们的一台服务器。但我总是收到530个不正确的登录信息 public static FTPClient connectToFTPServer() throws Exception { FTPClient client; client = new FTPClient(); client.enterLocalPassiveMode(); // important! client.addProtocolCo
public static FTPClient connectToFTPServer() throws Exception {
FTPClient client;
client = new FTPClient();
client.enterLocalPassiveMode(); // important!
client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
client.connect(ftpHost, ftpPort);
boolean loginSuccess = client.login("abc","abc");
if (!loginSuccess) {
client.logout();
client.disconnect();
throw new Exception("Connection could not be established with host " + ftpHost + " : " + ftpPort + " User "
);
}
//client.setFileType(FTP.BINARY_FILE_TYPE);
client.setFileType(2);
return client;
}
220 (vsFTPd 2.0.5)
USER abc
331 Please specify the password.
PASS abc
530 Login incorrect.
QUIT
221 Goodbye.
我可以使用ssh或sftp从putty登录到同一个服务器。任何人都面临类似的问题
提前谢谢
谢谢,
Ramki您提到连接使用ssh/sftp工作,但您没有使用FTPSClient。我也不知道client.enterLocalPassiveMode()是否;实际上是有效的。javadoc说:“当前调用任何connect方法都会将模式重置为*ACTIVE\u LOCAL\u DATA\u CONNECTION\u mode。”我删除了该语句。但是没有运气。我仍然看到同样的错误。我可以从cygwin中执行ssh或sftp。