You are in front of PC A, for e.g. your company firewall
PC A is under a network with a firewall that blocks outbound traffic to some websites.
You also have a public server (PC B) that is not under any firewall (or the firewall rule is setup by yourself.
There is a way that allow you to view the blocked website. With the following ssh tunnel you can use your browser under PC B's name from PC A
In PC A's command, execute
autossh -o "ServerAliveInterval 30" -o "ServerAliveCountMax 100" -D 1234 -CqNfT firstname.lastname@example.org
autossh: same command interface as
autosshautomatically restarts the command if it its terminated.
autosshneed to manually be installed. This command can be replaced with
o "ServerAliveInterval 30": for each 30 seconds, send a ping package to server in order to prevent the ssh connection from being terminated due to inactivity.
-o "ServerAliveCountMax 100": number of server alive messages sent when the server does not response, before terminating the connection.
-Dsock channel port specifier
-C: compress data
-q: quite mode, no warning
-N: open SSH connection with no command to be executed
-f: run background
-T: do not allocate a TTY-terminal, save a tiny amount of memory
Now your localhost serves as Sock proxy server at port
Open firefox -> preference -> network setting -> Proxy -> manually Sock host. And set
For Chrome (mac), execute
http_proxy=socks5://localhost:1234 open -a '/Applications/Google Chrome.app'
To open this sock connection whenever your PC startups. Refer to this blog post to setup a startup script.
Happy coding! <3