问题
How can I configure JSch client to communicate using network interface other than default one?
回答1:
I do not think that it is possible. I have the same requirement and checked the source code provided along with JSch. The plain Socket is created without a local address or port.
回答2:
You can implement the SocketFactory interface to create a custom socket with a specified source interface, and then use session.setSocketFactory(...) to plug it into your JSch session.
来源:https://stackoverflow.com/questions/8558833/open-ssh-connection-on-specific-network-interface-jsch