Skip to main content

Using ssh as proxy to bypass firewall, or use existing server to connect to internet

Prerequisite
1.       You have ssh access to a server, the server has public internet access
2.       On Windows, You can change proxy settings on your web browser or any program you want to access to internet, Or
3.       On Linux, You can compile c program

Tech explains:
ssh has a feature to enable socks 5 proxy server  on your own local machine when you connect to the server. Then on the local machine, configure proxy settings will let you use the internet access (or intranet access) on that server.
There’s also a program on Linux which can use http, socks4 or/and socks5 proxy to proxy any program. For example, you want to FTP to internet but the FTP program didn’t provide proxy settings, then you can use this program to do the proxy in the background for you.

Steps (for Windows):
1.       Connect to you server using ssh with below syntax:
    a.       ssh –D <local proxy port> -N <yourUserName>@<yourServer or IP address>
    b.      example:  ssh –D 9050 –N joe@myWebServer
    c.       when use putty: plink –D 9050 –N joe@myWebServer
2.       On you Windows machine, configure your program to use localhost port 9050 as Socks5 proxy, without use name and password.
3.       Try access sites you were not able to access
4.       You can also try programs like FreeCap to proxy everything, but as I tested, it won’t work on my PC.

Steps (for Linux – simple one):
1.       Connect to you server using ssh with below syntax:
    a.       ssh –D <local proxy port> -N <yourUserName>@<yourServer or IP address>
    b.      example:  ssh –D 9050 –N joe@myWebServer
    c.       when use putty: plink –D 9050 –N joe@myWebServer
2.       On you Windows machine, configure your program to use localhost port 9050 as Socks5 proxy, without use name and password.
3.       Try access sites you were not able to access

Steps (for Linux – advanced one):
1.       1. Download ProxyChains from http://proxychains.sourceforge.net to your Linux box
 2. Untar, unzip the file and compile, install it:
a.       tar xzf <downloaded file>
b.      cd <extracted directory>
c.       sh configure
d.      make
e.      make install
f.        Attention: For x64 system, you may hit error “object 'libproxychains.so' from LD_PRELOAD cannot be preloaded: ignored”,  when run proxychains, you can fix it by “ln –s /usr/lib/libproxychains.so /lib64”
3.       3. Connect to you server using ssh with below syntax:
a.       ssh –D <local proxy port> -N <yourUserName>@<yourServer or IP address>
b.      example:  ssh –D 9050 –N joe@myWebServer
c.       when use putty: plink –D 9050 –N joe@myWebServer
4.       4.edit /etc/proxychains.conf file, at the end of the file, under [ProxyList] section, add the socks5 server entry
a.       example: if you did as above, add “socks5 127.0.0.1 9050”
5.       5. start any of your program by “proxychains <your program>”
a.       example: proxychains firefox

Comments

Popular posts from this blog

How to send command / input to multiple Putty window simultaneously

Putty is one of the best and must-have freeware for people working on Linux/Unix but use Windows as client like me.  We need to manage many servers and sometimes we are hoping we can run/execute same command on multiple host at same time, or just input same thing to multiple host. I searched online for a tool can do this. And it looks like PuTTYCS (PuTTY Command Sender) is the only one existing. But I’m a little bit disappointing after tried the software, it’s good but not good enough. It can only send command to each window one by one, and you have to wait until last window got input. So I think I should do something, and puttyCluster was born ( https://github.com/mingbowan/puttyCluster ) interface is simple: When you input Windows title pattern in the text box, you will be prompt for how many windows matching the pattern, like this: and you click the edit box under “cluster input”, what ever key you pressed will pass to all those windows simultaneously, even “Ctrl-C”, “Esc” and

enable special character support in Graphite metric name

Problem Graphite doesn’t support special characters like “ “ (empty space), “/” slash etc. Because it expect everything to be just ASCII to split/processing them, and then make directories based on metric name. For example:   Metric:     datacenter1.server1.app1.metric1.abc Will create datacenter1/server1/app1/metric1/abc.wsp But Metric: datacentter1.this is a test/with/path.app.test will fail when create directory So any special name not allow to appear in directory/file name is not supported by Graphite.   What we can do?   We can urlEncode the metric name which has special characters. So like “/var/opt” (not valid file name) will become “%2Fvar%2Fopt”(now valid), using urlEncode instead of others (like BASE64) is because this will keep most of data readable.   So what to change? 1. urlEncode metric name before send to Graphite (if you always sending metrics using text/line mode instead of pickle/batch mode, then you may consider modify Carbon-cache.py), like     metricname=