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.

I have 2 servers, A and B. I want to create a tunnel from my system to server B but I have some limits to do this. So I have to first tunnel to server A and from server A to server B. My goal is to have a SOCKS Proxy to browse the web.

How can I do this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

I am showing you a very basic way to do it. Here I am assuming that B is directly accessible from A. There may be variations according to various situations.

On A:

ssh -D socks_port B

This will open up the port socks_port on A as a SOCKS proxy.

On your system:

ssh -L local_port:localhost:socks_port A

This will forward local_port on your system to port socks_port on A.

Then you can configure your browser to use SOCKS proxy on socket localhost:local_port


A one-liner would look like this:

ssh -t -L 1234:localhost:5678 FIRSTHOST ssh -D 5678 SECONDHOST

where FIRSTHOST and SECONDHOST have to be replaced by your hosts’ names or IP addresses.

In your browser you have to enter a socks proxy as:

localhost:1234
share|improve this answer

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.
{"cc_re__cc_re__cc_by_sa_3_0": ["sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=footerlink\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a>                   with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.12.19.2131\r\n            </div>\r\n                <div id=\"additional-notices\">\r\n                    Linux is a registered trademark of Linus Torvalds. UNIX is a registered trademark of The Open Group. <br>This site is not affiliated with Linus Torvalds or The Open Group in a"], "copyright__copyright__copyright": ["localhost:local_port\n\n\nA one-liner would look like this:\n\nssh -t -L 1234:localhost:5678 FIRSTHOST ssh -D 5678 SECONDHOST\n\nwhere FIRSTHOST and SECONDHOST have to be replaced by your hosts\u2019 names or IP addresses.\n\nIn your browser you have to enter a socks proxy as:\n\nlocalhost:1234\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}