gpt4 book ai didi

java - 与 FTPSClient 的 SFTP 连接失败

转载 作者:行者123 更新时间:2023-12-01 17:56:32 24 4
gpt4 key购买 nike

下面的代码我尝试使用FTPSClient连接SFTP主机。我使用 FTPSClient 进行连接,而不是 FTP 客户端。但我面临连接问题。

public static void main(String[] args) throws SocketException, IOException {
String host ="sftphost.com";
String user = "abc";
String pwd = "pwd"
final FTPSClient ftp = new FTPSClient();
System.out.println("host:"+host);
ftp.connect(host,22);
int reply = ftp.getReplyCode();
ftp.login(user, pwd);
}

最佳答案

FTPS is not SFTP .

您无法使用 Apache Commons Net FTPS 客户端 FTPSClient 连接到 SFTP 端口 22。这是一个完全不同的协议(protocol)。

您必须使用不同的库。最常用的 Java SFTP 库是 JSch .

另请参阅Secure FTP with org.apache.commons.net.ftp.FTPClient .

关于java - 与 FTPSClient 的 SFTP 连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44306082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com