Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using a VPN, I am connected through SSH on a distant Ubuntu Computer. From this computer, I can browse using telnet through a local server (192.168.x.x).

Is there any way, from the terminal or Firefox, to configure my browser to create a king of SSH tunnel so then I would be able to browse the 182.168.X.X directly in a GUI browser?

edit:

Example:

From my home (127.0.0.1), using a VPN, I connect myself through SSH computer: root@distant-server.com -p 5555. It's ip is 192.168.151.2

Once connected, I can browse to an intranet server as:

telnet 192.168.151.100 80
GET /index.html HTTP/1.0

What I do, is to configure something in my 127.0.0.1 Firefox GUI, so that I would be able to browse directly to 192.168.151.100.

edit 2:

For a strange reason, The problem has been fixed when I used SOCKS v4 instead of v5.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You can use DynamicForward ssh option, like this:

ssh -o DynamicForward=localhost:6661 yourserver

This way ssh client will listen on 6661 port on localhost for incoming connections. It implements SOCKS protocol so you can configure your Firefox or any other web browser to use this as a HTTP proxy server by using localhost:6661 address. This way all the HTTP requests made by Firefox will be actually made from your remote server so you an use 192.168.X.X addresses.

The shorer version of this is -D option which does the same:

ssh -D localhost:6661 yourserver

Saving yourself typing

You can also configure this option in .ssh/config file to save yourself typing if you want to enable this each time you connect to this host. Here's example:

host myhost
Hostname <yourvpnaddress>
DynamicForward localhost:6661
user <someuser>

Now, all you have to do is to run:

ssh myhost

and it will be equivalent to:

ssh -o DynamicForward=localhost:6661 -l <someuser> <yourvpnaddress>

Using proxy only for 192.168.X.X

If you want to only connect through this proxy when using 192.168.X.X addresses, you may use FoxyProxy Firefox extension (or something similar). It let you specify the list of proxy addresses associated only to specified URLs.

Using this proxy for other application

Some applications does not support SOCKS protocol so they can not be configured to use this method. Fortunately, there is solutions for this and it's called tsocks. It works as a wrapper converting all normal socket operations that application uses to the SOCKS request on the fly using LD_PRELOAD technique. It won't work for all the applications but it should for most. An alternative to tsocks is dante's socksify wrapper which also allows resolution of hostnames on the remote side.

share|improve this answer
    
I edited my previous post. So I test something like ssh -o DynamicForward=localhost:6661 root@distant-server.com -p 1151. My FF configuration use 127.0.0.1:6661 as SOCKS v5 proxy. Still does not work.. –  Pier-alexandre Bouchard Oct 5 '12 at 19:54
    
@Pier-alexandreBouchard: After you connect to the server using ssh, please check on your localhost (in another terminal, without leaving ssh session) if your ssh client is listening on 6661 port with nestat -tlp. Also, can you confirm that after closing ssh session, your FF can't connect to any site? If it can, your proxy settings are not working. Also ensure that 192.168.X.X is not excluded from using proxy in your FF settings. –  Krzysztof Adamski Oct 5 '12 at 19:56
    
netstat -l 127.0.0.1 returns nothing... –  Pier-alexandre Bouchard Oct 5 '12 at 20:07
    
@Pier-alexandreBouchard: By nothing you mean that there is no metion about ssh listening on port 6661, right? If so, then for some reason you ssh is not creating this tunel, does it complain when starting (like Could not request local forwarding.) ? –  Krzysztof Adamski Oct 5 '12 at 20:13
    
@Pier-alexandreBouchard: You can also add -v to your ssh command. You should get messages like: debug1: Local connections to localhost:6661 forwarded to remote address socks:0, debug1: Local forwarding listening on 127.0.0.1 port 6661. or similar. –  Krzysztof Adamski Oct 5 '12 at 20:18
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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