问题
Is it possible to do a reverse ssh connection using JSCH? If it is not, is there any other pure Java library that I can use to do a reverse tunnel SSH connection?
The command I want to mimic is similar than:
ssh -fN -R 7000:localhost:22 username@yourMachine-ipaddress
回答1:
There is an example gist that shows how to do it here: https://gist.github.com/ymnk/2318108#file-portforwardingr-java
The method you want to look at is session.setPortForwardingR()
session.setPortForwardingR(rport, lhost, lport);
来源:https://stackoverflow.com/questions/27883491/reverse-ssh-tunnel-with-jsch-java