【发布时间】:2014-01-07 18:14:35
【问题描述】:
我尝试使用库 commons.net 创建一个项目,以便通过 ftp 发送一些文件。但是我创建了与我的服务器的连接我收到了这个错误。
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-2.0-OpenSSH_5.3
我已关注此 article 来创建我的连接,并使用 official examples 我已控制文章。
我的java代码在这里:
private void connect(String host, String user, String pwd) {
try{
ftp = new FTPSClient(false);
//ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
int reply;
ftp.connect(host,22);//error is here
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
throw new Exception("Exception in connecting to FTP Server");
}
ftp.login(user, pwd);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
}catch(Exception ex){
ex.printStackTrace();
}
}
我不明白我哪里出错了。
【问题讨论】:
标签: java ssh apache-commons-net ftps