I have two pc (A & B, Both are running ubuntu 16.04) that are connected through Local Network. PC-A has Internet connection. I want to browse internet in PC-B using ssh tunneling.

I used the command in PC-B -

ssh -D 9999 user@IP_ADDRESS

Then i set HTTP, HTTPS, FTP Proxy empty and SOCKS Proxy "localhost" and port 9999.

If PC-A has Internet connection which is not requires proxy setup , then i can browse network in PC-B using above command.

But if PC-A has Internet conenction which requires HTTP Proxy "xxx.yy.zz.zz" and port 8080 then i can't browse internet using the above command and terminal shows following error:

"channel 3: open failed: connect failed: Connection refused".

What should i do ? Any help is appreciated.


Have you considered running a proxy server, maybe squid, on PC-A? Then you can create a tunnel from PC-B on a given port to the input port on PC-A of the squid daemon.

Then you can configure squid to either use another upstream proxy (http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/) or directly connect to the internet depending on what you need.


Answer to my own question is :

If PC-A has Internet connection with proxy (proxy_ip:port) and you want to access PC-A Internet connection in PC-B through local network connection using ssh then execute this command in terminal :

ssh -L random_port:proxy_ip:port username_A@ip_Address_A

Let's take an example :

PC-A :

  • username : linus
  • IP Address :
  • Runs on proxy:
  • Runs on port: 8080

chose a random port, 7856 (Randomly)

then in PC-B

ssh -L 7856: linus@

Then change the network setting :

  • HTTP/HTTPS PROXY : localhost or
  • PORT : random_port (In this case 7856)

Now You have Internet Connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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