I've tried to create a tunnel torward a client passed through a server, using the following command

ssh -X -f admin@IP_server -N -L 4444:IP_client:80

but when try to open client:80 by firefox receive as error this

channel 2: open failed: unknown channel type: 
Connection to closed by remote host.

someone knows where is the issue? thanks so much


Here's what I use to load my webmin on my servers (which is firewalled away so only somebody with ssh access can see it):

ssh -l oli -L 9090:localhost:9090 my-server-ip

That connects me to the server and maps my local port 9090 to the server's P9090. I just browse at http://localhost:9090/ and I can see the webmin.

If you're trying to connect to another device through your server, you don't really want to faff around with manual tunnel options. ssh has a built-in SOCKS proxy mode. Run this:

ssh -D 9999 oli@my-server-ip

Then you tell your browser about the SOCKS proxy. Look under the network settings. localhost as the server, port 9999. Remember this has to be under the setting for SOCKS. This is not a HTTP proxy.

Now when you browse, all the traffic goes through the ssh tunnel. This means if there's a device on the other end that only your server can reach, you can connect to that using its IP.

Note that DNS lookups and other network traffic won't go through the tunnel (AFAIK) so you need to connect to an IP if it makes a difference (which I suspect it will in this case)

  • If I've to connect to a remote server that suggest is fine, my issue is to reach a VoIP phone which is situated back a PBX. So the topology is the following PC -> Internet -> PBX -> VoIP phone. The PBX is a network device as a router. – Riccardo Magrini Mar 5 '11 at 15:44
  • I know that using putty can make it but I want make it using Ubuntu – Riccardo Magrini Mar 5 '11 at 15:52
  • I get a SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1 Protocol mismatch in Firefox – nicoX Oct 4 '13 at 8:15
  • @nicoX I assume you're using the second, proxy method. Make sure you've put it in the SOCKS Host box and not the HTTP Proxy input. – Oli Oct 4 '13 at 8:26
  • @oli I'm on a local network. ssh -R 4444:localhost:22 desktopX@<IP> from my VirtualBox server to my Ubuntu desktop client. From my desktop client I run ssh -D 4444 clientX@<IP>. I tried SOCKS but it don't work. – nicoX Oct 4 '13 at 8:51

You want a reverse Tunnel, try this:

ssh -NT -R 4444:local.mydomain.com:80 user@remote.mydomain.com

What this does is initiate a connection to remote.mydomain.com and forwards TCP port 4444 on remote.mydomain.com to TCP port 80 on local.mydomain.com. "-N" tells ssh to just set up the tunnel and not to prepare a command stream, and "-T" tells ssh not to allocate a pseudo-tty on the remote system. The "-R" option tells ssh to set up the tunnel as a reverse tunnel.

  • I've to pass through a server to reach a VoIP phone and open its own web interface to make some configuration on it. – Riccardo Magrini Mar 4 '11 at 23:17

Your description is confusing. As specified, you have told it that connections to localhost:4444 are to be forwarded to IP_server which should then connect to IP_client:80, but then you are connecting directly to IP_client:80?

  • I'm sorry I've explained it bad.you right! My situation is the following: client -> remote_server -> voip phone. I should create a tunnel on the remote server to have the possibility of accessing to the graphic's interface of VoIP phone by firefox. I tried gSTM but receive the same error – Riccardo Magrini Mar 4 '11 at 22:44

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.