How to connect to an FTP server from an existing connection to Unix server?

五迷三道 提交于 2019-12-03 21:53:38

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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!