更新时间: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);