[JSch-users] port 22 forwarding
Status: Alpha
Brought to you by:
ymnk
From: Jean-Philippe P. <jp...@gm...> - 2009-01-14 09:08:46
|
Hello, I am trying to to forward the port 22 of host B to the port 51501 on host A. I got no error but if I try to connect to host A on port 51501 I get a connection refused : ssh -p 51501 ssh: connect to host prod port 51501: Connection refused here is my code String host="A"; String user="user";; int port=22; int tunnelLocalPort=51501; String tunnelRemoteHost="B"; int tunnelRemotePort=22; JSch jsch=new JSch(); session=jsch.getSession(user, host, port); MyUser lui=new MyUser(); session.setUserInfo(lui); session.connect(); //session.setPortForwardingL(tunnelLocalPort,tunnelRemoteHost,tunnelRemotePort); session.setPortForwardingL("0.0.0.0",tunnelLocalPort,tunnelRemoteHost,tunnelRemotePort); System.out.println("Connected"); If I try to set up manualy : I connect to host A and then execute : ssh -Ng -L 50123:localhost:22 user@B then if I try to connect to host A on port 50123 it works running netstats on host A : netstat -an | grep 50123 tcp 0 0 0.0.0.0:50123 0.0.0.0:* LISTEN When using jsch I have no error/ exception, but if I run "netstat -an | grep 51501 " it is empty... What am I doing wrong ? The example look simple but I can't achieve to make it works.... Thanks for help ! |