且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从现有的连接到Unix服务器连接到FTP服务器?

更新时间:2023-02-03 23:20:02

You typically use the local port forwarding for this.

In JSch, after you connect, call the setPortForwardingL:

int ftpPort = session.setPortForwardingL(0, "someftp.example.com", 21);

And then connect a local FTP client (e.g. the FTPClient from Apache Commons) to the localhost:ftpPort:

FTPClient ftp = new FTPClient();
ftp.connect("localhost", ftpPort);
ftp.login("myLogin", password);